#include <bits/stdc++.h>
#include "testlib.h"

using namespace std;

int n, k;
vector<pair<int, int>> line;


int readAndCheckAnswer(InStream &in) {
    int m = in.readInt(-1, n, "m");
    if (m == -1) {
        return -1;
    }
    if (m < 2) {
        in.quitf(_wa, "Length of the sequence must be at least 2, but %d found", m);
    }
    vector<int> inds = in.readInts(m, 1, n, "inds");
    bool have_break = false;
    for (int i = 1; i < m; i++) {
        in.ensuref(line[inds[i - 1] - 1].second <= line[inds[i] - 1].first,
                   "%d-th game starts before the end of %d-th: %d >= %d", i + 1, i,
                   line[inds[i - 1] - 1].second, line[inds[i] - 1].first);
        have_break |= line[inds[i - 1] - 1].second + k <= line[inds[i] - 1].first;
    }
    in.ensuref(have_break, "No long enough break found");
    return m;
}


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

    n = inf.readInt();
    k = inf.readInt();
    line.resize(n);
    for (auto& [a, b] : line) {
        a = inf.readInt();
        b = inf.readInt();
    }
    int j_ans = readAndCheckAnswer(ans);
    int p_ans = readAndCheckAnswer(ouf);

    if (j_ans == -1) {
        if (p_ans != -1) {
            quitf(_fail, "Participant found the sequence, but jury didn't");
        } else {
            quitf(_ok, "No sequence exists");
        }
    } else {
        if (p_ans == -1) {
            quitf(_wa, "Participant didn't find the sequence, but jury did");
        } else if (p_ans < j_ans) {
            quitf(_wa, "Participant's answer is worse than jury's, %d < %d", p_ans, j_ans);
        } else if (p_ans > j_ans) {
            quitf(_fail, "Participant's answer is better than jury's, %d > %d", p_ans, j_ans);
        } else {
            quitf(_ok, "Participant's answer is correct");
        }
    }
}
