#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
#ifdef home
    freopen("f.in", "r", stdin);
    freopen("f.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, n, M, m, k, q;
    cin >> N >> n >> M >> m >> k >> q;
    vector<int> a, b;
    while (n--) {
        int l, v;
        cin >> l >> v;
        v--;
        while (l--) {
            a.emplace_back(v);
        }
    }
    while (m--) {
        int l, v;
        cin >> l >> v;
        v--;
        while (l--) {
            b.emplace_back(v);
        }
    }
    n = N, m = M;
    vector<vector<int>> clsa(n, vector<int>(k, -1));
    vector<vector<int>> clsb(m, vector<int>(k, -1));
    for (int i = 1; i < n; i++) {
        clsa[i] = clsa[i - 1];
        clsa[i][a[i - 1]] = i - 1;
    }
    for (int i = 1; i < m; i++) {
        clsb[i] = clsb[i - 1];
        clsb[i][b[i - 1]] = i - 1;
    }
    vector<set<int>> xs(n);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            xs[i].emplace(j);
        }
    }
    vector<vector<int>> dp(n, vector<int>(m, 0));
    for (int x = n - 1; x >= 0; x--) {
        for (int y = m - 1; y >= 0; y--) {
            if (a[x] == b[y]) {
                if (dp[x][y] == 1) {
                    continue;
                }
                int c = a[x];
                int cx = clsa[x][c], cy = clsb[y][c];
                if (cx < 0) {
                    cx = 0;
                }
                if (cy < 0) {
                    cy = 0;
                }
                for (int px = cx; px < x; px++) {
                    vector<int> buff;
                    for (auto it = xs[px].lower_bound(cy); it != xs[px].end(); ++it) {
                        int py = *it;
                        if (py >= y) {
                            break;
                        }
                        buff.emplace_back(py);
                        dp[px][py] = 1;
                    }
                    for (auto &el: buff) {
                        xs[px].erase(el);
                    }
                }
            }
        }
    }
    for (int i = n - 1; i >= 0; i--) {
        if (i + 1 < n) {
            clsa[i] = clsa[i + 1];
        }
        clsa[i][a[i]] = i;
    }
    for (int i = m - 1; i >= 0; i--) {
        if (i + 1 < m) {
            clsb[i] = clsb[i + 1];
        }
        clsb[i][b[i]] = i;
    }
    while (q--) {
        int x, y;
        cin >> x >> y;
        bool good = false;
        for (int c = 0; c < k; c++) {
            if (clsa[x][c] == n || clsb[y][c] == m) {
                continue;
            }
            if (!dp[clsa[x][c]][clsb[y][c]]) {
                good = true;
            }
        }
        cout << (good ? "Yes\n" : "No\n");
    }
    return 0;
}
