#include "testlib.h"

#include <set>
#include <utility>

using namespace std;

set< pair<int, int> > Q;
set<int> W;

int main()
{
    registerValidation();
    
    int N = inf.readInt(1, 100);
    inf.readSpace();
    int M = inf.readInt(1, 100);
    inf.readSpace();
    int P = inf.readInt(0, M);
    inf.readSpace();
    int K = inf.readInt(1, min(1000, N*(M - 1)));
    inf.readEoln();
    for (int i = 0; i < P; ++i) {
        if (i > 0) {
            inf.readSpace();
        }
        int p = inf.readInt(1, M);
        if (W.count(p) > 0) {
            quit(_fail, "coincident white pawns");
        }
        W.insert(p);
    }
    inf.readEoln();

    for (int i = 0; i < K; ++i) {
        int x = inf.readInt(2, N);
        inf.readSpace();
        int y = inf.readInt(1, M);
        inf.readEoln();
        if (Q.count(make_pair(x, y)) > 0) {
            quit(_fail, "coincident black pieces");
        }
        Q.insert(make_pair(x, y));
    }
    inf.readEof();

    return 0;
}
