#include <bits/stdc++.h>

using namespace std;

signed main() {
    int N, n, M, m, k, q;
    cin >> N >> n >> M >> m >> k >> q;
    vector<int> a, b;
    for (int i = 0; i < n; i++) {
        int l, x;
        cin >> l >> x;
        for (int j = 0; j < l; j++) a.push_back(x);
    }
    for (int i = 0; i < m; i++) {
        int l, x;
        cin >> l >> x;
        for (int j = 0; j < l; j++) b.push_back(x);
    }
    n = N, m = M;
    vector<vector<int>> dp(n, vector<int>(m));
    vector<vector<int>> nxt(n, vector<int>(m));
    for (int i = n - 1; i >= 0; i--) {
        for (int j = m - 1; j >= 0; j--) {
            if (a[i] == b[j]) {
                if (i + 1 < n && j + 1 < m) {
                    dp[i][j] = 1 - dp[i + 1][j + 1];
                } else {
                    dp[i][j] = 1;
                }
                if (i + 1 < n && j + 1 < m) {
                    nxt[i][j] = nxt[i + 1][j + 1];
                    dp[i][j] = max(dp[i][j], nxt[i][j]);
                }
            } else {
                if (i + 1 < n) {
                    nxt[i][j] = dp[i][j] = max(dp[i][j], dp[i + 1][j]);
                }
                if (j + 1 < m) {
                    nxt[i][j] = dp[i][j] = max(dp[i][j], dp[i][j + 1]);
                }
            }
            // cout << i << " " << j << ": " << dp[i][j] << "\n";
        }
    }
    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        if (dp[x][y]) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
}