/*#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")*/

#include <iostream>
#include <math.h>
#include <iostream>
#include <string>
#include <fstream>
#include <set>
#include <vector>
#include <algorithm>
#include <random>

using namespace std;
using ll = long long;
using ld = long double;
const ll MAXN = 5e3+5;
const ll MOD = 1e9 + 7;
bool dp[MAXN][MAXN];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll N,n,M,m,k,q,l,a,x,y;
    cin >> N >> n >> M >> m >> k >> q;
    ll res = 0;
    vector<ll> arr1;
    vector<ll> arr2;
    vector<vector<int>> ind1(N+1,vector<int>(k+1,-1));
    vector<vector<int>> ind2(M+1,vector<int>(k+1,-1));
    for (int i = 0;i<n;i++){
        cin >> l >> a;
        for (int j = 0;j<l;j++){
            arr1.push_back(a);
        }
    }
    for (int i = 0;i<m;i++){
        cin >> l >> a;
        for (int j = 0;j<l;j++){
            arr2.push_back(a);
        }
    }
    ll per;
    per = -1;
    for (int i = N-1;i>-1;i--){
        for (int pk = 0;pk<=k;pk++){
            ind1[i][pk] = ind1[i+1][pk];
        }
        if (per != -1){
            ind1[i][per] = i + 1;
        }
        per = arr1[i];
    }
    per = -1;
    for (int i = M-1;i>-1;i--){
        for (int pk = 0;pk<=k;pk++){
            ind2[i][pk] = ind2[i+1][pk];
        }
        if (per != -1){
            ind2[i][per] = i + 1;
        }
        per = arr2[i];
    }
    bool flag;
    for (ll i = N-1;i>-1;i--){
        for (ll j = M-1;j>-1;j--){
            if (arr1[i] == arr2[j]){
                flag = false;
                for (int t = 1;t<=k;t++){
                    if (ind1[i][t] != -1 && ind2[j][t] != -1){
                        if (dp[ind1[i][t]][ind2[j][t]]){
                            flag = true;
                            break;
                        }
                    }
                }
                if (!flag){
                    dp[i][j] = true;
                }
            }
        }
    }
    for (int i = 0;i<q;i++){
        cin >> x >> y;
        if (dp[x][y]){
            cout << "Yes" << "\n";
        }
        else{
            cout << "No" << "\n";
        }
    }
}
