#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")

#include <bits/stdc++.h>

#pragma GCC target("avx,avx2,bmi,bmi2,sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,tune=native")

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int nn, n, mm, m, k, q;
    cin >> nn >> n >> mm >> m >> k >> q;
    vector<int> arr1, arr2;
    for(int i = 0; i < n; i++) {
        int k, v;
        cin >> k >> v;
        while(k--) arr1.push_back(v);
    }
    for(int i = 0; i < m; i++) {
        int k, v;
        cin >> k >> v;
        while(k--) arr2.push_back(v);
    }

    vector<vector<int>> nxt1(arr1.size() + 1, vector<int>(k, arr1.size()));
    for(int i = arr1.size() - 1; i >= 0; i--) {
        for(int j = 0; j < k; j++) nxt1[i][j] = nxt1[i + 1][j];
        nxt1[i][arr1[i] - 1] = i;
    }

    vector<vector<int>> nxt2(arr1.size() + 1, vector<int>(k, arr2.size()));
    for(int i = arr2.size() - 1; i >= 0; i--) {
        for(int j = 0; j < k; j++) nxt2[i][j] = nxt2[i + 1][j];
        nxt2[i][arr2[i] - 1] = i;
    }

    vector<vector<int>> dp(arr1.size() + 1, vector<int>(arr2.size() + 1));
    for(int i = arr1.size() - 1; i >= 0; i--) {
        for(int j = arr2.size() - 1; j >= 0; j--) {
            for(int t = 0; t < k; t++) {
                // int ii = i, jj = j;
                // while(ii < arr1.size() && arr1[ii] != t) ii++;
                // while(jj < arr2.size() && arr2[jj] != t) jj++;
                int ii = nxt1[i][t], jj = nxt2[j][t];
                if((ii == arr1.size() || jj == arr2.size())) continue;
                if(dp[ii + 1][jj + 1] == 0) {
                    dp[i][j] = 1;
                    break;
                }
            }
        }
    }
    while(q--) {
        int a, b;
        cin >> a >> b;
        int ans = dp[a][b];
        if(ans) cout << "Yes\n";
        else cout << "No\n";
    }
}
