#include<bits/stdc++.h>
using namespace std;

void solve() {
    int N, n, M, m, k, q;
    cin >> N >> n >> M >> m >> k >> q;
    vector<array<int, 2>> a, b;
    vector<int> a2, b2;
    for (int t = 0; t < n; t++) {
        int l, v;
        cin >> l >> v;
        a.push_back({l, v});
    }
    for (int t = 0; t < m; t++) {
        int l, v;
        cin >> l >> v;
        b.push_back({l, v});
    }
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    int N2 = 0, M2 = 0;
    for (int i = 0; i < n - 1; i++) {
        N2 += a[i][0];
    }
    for (int i = 0; i < m - 1; i++) {
        M2 += b[i][0];
    }
    a2.assign(N2 + 1, 0);
    b2.assign(M2 + 1, 0);
    for (int t = 0, i = 1; t < n - 1; t++) {
        for (int j = 0; j < a[t][0]; j++) {
            a2[i] = a[t][1];
            i++;
        }
    }
    for (int t = 0, i = 1; t < m - 1; t++) {
        for (int j = 0; j < b[t][0]; j++) {
            b2[i] = b[t][1];
            i++;
        }
    }
    vector<vector<int>> dp(N2 + 2, vector<int>(M2 + 2));
    vector<int> last1(k + 1, 0);
    for (int i = 1; i <= N2; i++) {
        last1[a2[i]] = i;
        vector<int> last2(k + 1, 0);
        for (int j = 1; j <= M2; j++) {
            last2[b2[j]] = j;
            for (int v = 1; v <= k; v++) {
                if (last1[v] >= 1 && last2[v] >= 1 && !dp[last1[v] - 1][last2[v] - 1]) {
                    dp[i][j] = 1;
                    break;
                }
            }
        }
    }
    while (q--) {
        int x, y;
        cin >> x >> y;
        x = N - x;
        y = M - y;
        if (x > N2 && y > M2) {
            if (dp[N2][M2]) {
                cout << "YES\n";
                continue;
            }
            int v = min(x - N2, y - N2);
            cout << (v % 2 == 1 ? "YES" : "NO") << '\n';
            continue;
        }
        x = min(x, N2);
        y = min(y, N2);
        cout << (dp[x][y] ? "YES" : "NO") << '\n';
    }
}

int32_t main() {
    cin.tie(0);
    ios::sync_with_stdio(0);

    solve();
}
