#include <bits/stdc++.h>

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);
    }
    while(q--) {
        int a, b;
        cin >> a >> b;
        vector<int> aa, bb;
        for(int i = a; i < nn; i++) aa.push_back(arr1[i]);
        for(int i = b; i < mm; i++) bb.push_back(arr2[i]);
        vector<vector<int>> dp(aa.size() + 1, vector<int>(bb.size() + 1));
        // dp[aa.size()][bb.size()] = 1;
        for(int i = aa.size() - 1; i >= 0; i--) {
            for(int j = bb.size() - 1; j >= 0; j--) {
                // if(aa[i] != bb[j]) continue;
                for(int t = 1; t <= k; t++) {
                    // if(t == aa[i]) continue;
                    int ii = i + 1, jj = j + 1;
                    while(ii < aa.size() && aa[ii] != t) ii++;
                    while(jj < bb.size() && bb[jj] != t) jj++;
                    if(ii == aa.size() || jj == bb.size()) continue;
                    // if(ii == aa.size() || jj == bb.size()) continue;
                    if(dp[ii][jj] == 0) {
                        dp[i][j] = 1;
                    }
                }
            }
        }
        // cout << "====\n";
        // for(auto i : dp) {
        //     for(auto j : i) cout << j << ' ';
        //     cout << '\n';
        // }
        // cout << dp[0][0] << '\n';
        if(dp[0][0] == 0) cout << "Yes\n";
        else cout << "No\n";
    }
}
