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

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

    solve();
}
