#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
bool dp[5003][5003], used[5003][5003];
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, n, M, m, k, q; cin >> N >> n >> M >> m >> k >> q;
    vector<int> a(N + 1), b(M + 1);
    int last = 0;
    for (int i = 1; i <= n; ++i) {
        int len; cin >> len;
        int val; cin >> val;
        for (int j = last + 1; j <= last + len; ++j) a[j] = val;
        last += len;
    }
    last = 0;
    for (int i = 1; i <= m; ++i) {
        int len; cin >> len;
        int val; cin >> val;
        for (int j = last + 1; j <= last + len; ++j) b[j] = val;
        last += len;
    }
    vector<vector<int>> nxt1(k + 2, vector<int>(N + 2, N + 1)),
                        nxt2(k + 2, vector<int>(M + 2, M + 1));
    for (int i = 1; i <= k; ++i) {
        for (int j = N; j >= 1; --j) {
            if (a[j] == i) nxt1[i][j] = j;
            else nxt1[i][j] = nxt1[i][j + 1];
        }
    }
    for (int i = 1; i <= k; ++i) {
        for (int j = M; j >= 1; --j) {
            if (b[j] == i) nxt2[i][j] = j;
            else nxt2[i][j] = nxt2[i][j + 1];
        }
    }
    vector<int> cnt(k + 1);
    for (int i = 1; i <= N; ++i) cnt[a[i]]++;
    vector<int> cnt2(k + 1);
    for (int i = 1; i <= M; ++i) cnt2[b[i]]++;
    for (int i = 1; i <= k; ++i) cnt[i] = min(cnt[i], cnt2[i]);
    vector<int> color;
    for (int i = 1; i <= k; ++i) if (cnt[i] > 0) color.push_back(i);
    sort(color.begin(), color.end(), [&](int p1, int p2) {
         return cnt[p1] > cnt[p2];
    });
    function<bool(int, int)> f = [&](int f1, int f2) {
        if (f1 > N || f2 > M) {
            return false;
        }
        if (used[f1][f2] == true) {
            return dp[f1][f2];
        }
        used[f1][f2] = true;
        if (a[f1] == b[f2]) {
            if (f(f1 + 1, f2 + 1) == false) {
                return dp[f1][f2] = true;
            }
        }
       /* if (f(f1 + 1, f2) == false) {
            return dp[f1][f2] = true;
        }*/
        for (auto nxt : color) {
            int f11 = nxt1[nxt][f1], f22 = nxt2[nxt][f2];
            if (f11 <= N && f22 <= M && f(f11 + 1,f22 + 1) == false) {
                return dp[f1][f2] = true;
            }
        }
        return dp[f1][f2] = false;
    };
    while (q--) {
        int x, y; cin >> x >> y;
        x++, y++;
        if (f(x, y)) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
    return 0;
}
