#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

#define int ll
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using ordered_set = __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

mt19937 rnd(time(0));

inline void solve() {
    int N, n, M, m, k, q;
    cin >> N >> n >> M >> m >> k >> q;
    vector<int> a(N), b(M);
    int cur = 0;
    for (int i = 0; i < n; i++) {
        int l;
        cin >> l;
        int x;
        cin >> x;
        while (l--) {
            a[cur] = x;
            cur++;
        }
    }
    cur = 0;
    for (int i = 0; i < m; i++) {
        int l;
        cin >> l;
        int x;
        cin >> x;
        while (l--) {
            b[cur] = x;
            cur++;
        }
    }
    n = N;
    m = M;
    vector<vector<int>> e1(n, vector<int>(k + 1));
    vector<vector<int>> e2(m, vector<int>(k + 1));
    for (int i = 0; i <= k; i++) {
        for (int j = n - 1; j >= 0; j--) {
            if (j < n - 1 && a[j + 1] == i) {
                e1[j][i] = j + 1;
            } else {
                if (j == n - 1) {
                    e1[j][i] = -1;
                } else {
                    e1[j][i] = e1[j + 1][i];
                }
            }
        }
        for (int j = m - 1; j >= 0; j--) {
            if (j < m - 1 && b[j + 1] == i) {
                e2[j][i] = j + 1;
            } else {
                if (j == m - 1) {
                    e2[j][i] = -1;
                } else {
                    e2[j][i] = e2[j + 1][i];
                }
            }
        }
    }
    vector<vector<pii>> dp(n + 1, vector<pii>(m + 1));
    for (int i = n - 1; i >= 0; i--) {
        for (int j = m - 1; j >= 0; j--) {
            if (a[i] == b[j]) {
                for (int nxt = 1; nxt <= k; nxt++) {
                    if (nxt == a[i]) continue;
                    if (e1[i][nxt] != -1 && e2[j][nxt] != -1)
                        dp[i][j].second |= (dp[e1[i][nxt]][e2[j][nxt]].first);
                }
                bool f = true;
                for (int nxt = 1; nxt <= k; nxt++) {
                    if (e1[i][nxt] != -1 && e2[j][nxt] != -1) {
                        if (dp[e1[i][nxt]][e2[j][nxt]].first || dp[e1[i][nxt]][e2[j][nxt]].second) {
                            f = false;
                            break;
                        }
                    }
                }
                if (f)
                    dp[i][j].first = 1;
            }
        }
    }
    while (q--) {
        int x, y;
        cin >> x >> y;
        if (!dp[x][y].first) {
            cout << "No\n";
        } else {
            cout << "Yes\n";
        }
    }
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) solve();
}