#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int dp[5001][5001];

void solve() {
    int N, n, M, m, k, q; cin >> N >> n >> M >> m >> k >> q;
    vector<int> a(N + 1), b(M + 1);
    int idx = 1;
    for (int i = 0; i < n; i++) {
        int l, v; cin >> l >> v; v--;
        for (int j = 0; j < l; j++) {a[idx++] = v;}
    }
    idx = 1;
    for (int i = 0; i < m; i++) {
        int l, v; cin >> l >> v; v--;
        for (int j = 0; j < l; j++) {b[idx++] = v;}
    }
    k++;
    a[0] = b[0]  = k - 1;
    n = N + 1; m = M + 1;
    // for (int u : a) cout << u<<' ';
    // cout << '\n';
    // for (int v : b) cout << v << ' ' ;
    // cout << '\n';

    for (int p2 = m - 1; p2 >= 0; p2--) {
        vector<int> nxt(k, -1);
        for (int j = p2 + 1; j < m; j++) if (nxt[b[j]] == -1) nxt[b[j]] = j;
        int cnt_lose = 0;
        vector<int> nxt2(k, -1);
        for (int p1 = n - 1; p1 >= 0; p1--) {
            //cout << p1 << ' ' << p2 << ' ' << (cnt_lose == 0 ? 0 : 1) << '\n';
            //if (a[p1] == b[p2]) {
                dp[p1][p2] = (cnt_lose == 0 ? 0 : 1);
            //}
            //if (p2 == 3) cout << p1 << ' ' << cnt_lose << '\n';
            if (nxt2[a[p1]] != -1 && nxt[a[p1]] != -1) {
                cnt_lose -= (1 - dp[nxt2[a[p1]]][nxt[a[p1]]]);
            }
            if (nxt[a[p1]] != -1) {
                cnt_lose += 1 - dp[p1][nxt[a[p1]]];
            }
            nxt2[a[p1]] = p1;
        }
    }
    while (q--) {
        int x, y; cin >> x >> y;
        cout << (dp[x][y] ? "Yes\n" : "No\n");
    }
}

signed main() {
    int tt = 1;
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        cin >> tt;
    #else
        cin.tie(0)->sync_with_stdio(false);
    #endif  

    while (tt--) {
        solve();
    }

    return 0;
}