#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

const int inf = 1e9 + 7;
const int maxn = 5000 + 10;
vector<vector<int>> dp(maxn, vector<int>(maxn, -1));
const int maxk = 1600 + 10;
vector<vector<int>> lst(2, vector<int>(maxn, 0));
vector<int> siz_lst(2, 0);
vector<vector<vector<int>>> next_symv(2, vector<vector<int>>(maxk, vector<int>(maxn, inf)));
vector<vector<vector<int>>> all_indes(2, vector<vector<int>>(maxk, vector<int>()));
int all_n, n, all_m, m, k, q;

void make_all_lists() {
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < siz_lst[i]; j++) {
            all_indes[i][lst[i][j]].push_back(j);
        }
    }
    for (int i = 0; i < 2; i++) {
        for (int symv = 0; symv < maxk; symv++) {
            for (int j = siz_lst[i] - 1; j >= 0; --j) {
                if (j == siz_lst[i] - 1 || lst[i][j + 1] != symv) {
                    next_symv[i][symv][j] = next_symv[i][symv][j + 1];
                } else {
                    next_symv[i][symv][j] = j + 1;
                }
            }
        }
    }
}

void make_dp(int a, int b) {
    for (int symv = 0; symv <= k; symv++) {
        if (dp[a][b] != -1) {
            return;
        }
        int c = next_symv[0][symv][a];
        int d = next_symv[1][symv][b];
        if (c != inf && d != inf) {

            make_dp(c, d);
            if (dp[c][d] == 0) {
                dp[a][b] = 1;
                return;
            }
        }
    }
    if (dp[a][b] == -1) {
        dp[a][b] = 0;
    }
}

int find_near(int ind, int symv, int min_val) {
    int l = -1, r = all_indes[ind][symv].size();
    while (l + 1 < r) {
        int mid = (l + r) / 2;
        if (all_indes[ind][symv][mid] >= min_val) {
            r = mid;
        } else {
            l = mid;
        }
    }
    if (r == all_indes[ind][symv].size()) {
        return inf;
    }
    return all_indes[ind][symv][r];
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
    cin >> all_n >> n >> all_m >> m >> k >> q;
    int start = 0;
    for (int i = 0; i < n; i++) {
        int siz, symv;
        cin >> siz >> symv;
        for (int j = start; j < start + siz; j++) {
            lst[0][j] = symv;
        }
        start += siz;
    }
    start = 0;
    for (int i = 0; i < m; i++) {
        int siz, symv;
        cin >> siz >> symv;
        for (int j = start; j < start + siz; j++) {
            lst[1][j] = symv;
        }
        start += siz;
    }
    make_all_lists();
    for (int i = 0; i < all_n; i++) {
        for (int j = 0; j < all_m; j++) {
            make_dp(i, j);
        }
    }
    for (; q > 0; --q) {
        int x, y;
        cin >> x >> y;
        bool check_alice_won = false;
        for (int symv = 1; symv <= k; symv++) {
            int a = find_near(0, symv, x);
            int b = find_near(1, symv, y);
            if (a != inf && b != inf) {
                if (dp[a][b] == 0) {
                    check_alice_won = true;
                    break;
                }
            }
        }
        if (check_alice_won) {
            cout << "Yes" << '\n';
        } else {
            cout << "No" << '\n';
        }
    }
}
