#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include "testlib.h"

using namespace std;

#define VI vector<int>

#define FOR(i,n) for (int i = 0; i < (int)(n); i++)

#define PB push_back
#define SZ(a) a.size()
#define MP make_pair
#define PII pair<int, int>
#define VI vector<int>
#define VVI vector<VI >
#define PII pair<int, int>

int n, res;

int m[512][512], rc[512], cc[512];

int x[512], y[512];

int main(int argc, char *argv[])
{
	registerTestlibCmd(argc, argv);

	n = inf.readInteger();
	for (int i = 1; i <= n; i++)
	{
		x[i] = inf.readInteger();
		y[i] = inf.readInteger();
		rc[x[i]]++;
		cc[y[i]]++;
		m[x[i]][y[i]]++;
	}

	res = ans.readInteger();
	int res_o = ouf.readInteger();
	if (res_o != res)
		quitf(_wa, "Wrong number of moves. Judge's: %d, output %d", res, res_o);

	for (int i = 0; i < res; i++)
	{
		int k = ouf.readInteger();
		string dir = ouf.readWord();
		rc[x[k]]--;
		cc[y[k]]--;
		m[x[k]][y[k]]--;
		if (dir == "L")
			y[k]--;
		else if (dir == "R")
			y[k]++;
		else if (dir == "U")
			x[k]--;
		else if (dir == "D")
			x[k]++;
		if (x[k] < 1 || x[k] > n || y[k] < 1 || y[k] > n)
			quitf(_wa, "Incorrect step (%d, %d)", x[k], y[k]);
		if (m[x[k]][y[k]])
		        quitf(_wa, "Step into occupied cell (%d, %d)", x[k], y[k]);
		rc[x[k]]++;
		cc[y[k]]++;
		m[x[k]][y[k]]++;
	}

	for (int i = 1; i <= n; i++)
	{
		if (cc[i] != 1)
			quitf(_wa, "Wrong number of tanks in column %d: %d", i, cc[i]);
		if (rc[i] != 1)
			quitf(_wa, "Wrong number of tanks in row %d: %d", i, rc[i]);
	}

	quitf(_ok, "OK %d, %d moves", n, res);
}
