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

void solve() {
    int N, n, M, m, k, q;
    cin >> N >> n >> M >> m >> k >> q;
    vector<int> a(N + 1), b(M + 1);
    for (int t = 0, i = 1; t < n; t++) {
        int l, v;
        cin >> l >> v;
        for (int j = 0; j < l; j++) {
            a[i] = v;
            i++;
        }
    }
    for (int t = 0, i = 1; t < m; t++) {
        int l, v;
        cin >> l >> v;
        for (int j = 0; j < l; j++) {
            b[i] = v;
            i++;
        }
    }
    vector<vector<int>> dp(N + 2, vector<int>(M + 2));
    vector<int> last1(k + 1, N + 1);
    b[0] = -1;
    for (int i = N; i >= 1; i--) {
        last1[a[i]] = i;
        vector<int> last2(k + 1, M + 1);
        set<int> c;
        for (int j = M; j >= 1; j--) {
            last2[b[j]] = j;
            c.erase(b[j]);
            if (last1[b[j]] <= N && !dp[last1[b[j]] + 1][j + 1]) c.insert(b[j]);
            dp[i][j] = (!c.empty());
        }
    }
    while (q--) {
        int x, y;
        cin >> x >> y;
        x++;
        y++;
        cout << (dp[x][y] ? "YES" : "NO") << '\n';
    }
}

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

    solve();
}
