#include <bits/stdc++.h>

using namespace std;

void solve();

//#pragma GCC optimize("O3","Ofast","fastmath","unroll-loops")
//#pragma GCC target("avx2","sse4.2","bmi","lzcnt","popcnt")
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
   // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

#define int long long
#define endl '\n'
const int N = 5e3 + 1, INF = 2e9, MOD = 1e9 + 7;

bool dp[N][N];
int nxa[N][1601];
int nxb[N][1601];
int pra[N][1601];
int prb[N][1601];

void solve() {
    int nb,n,mb,m,k,q;
    cin>>nb>>n>>mb>>m>>k>>q;

    vector<vector<int>> can(nb);
    vector<int> a,b;
    for(int i=0;i<n;i++){
        int f,s;
        cin>>f>>s;
        while(f--){
            a.push_back(s);
        }
    }
    map<int,int> prev;
    for(int i=nb-1;i>=0;i--){
        prev[a[i]]=i;
        for(int j=0;j<=k;j++){
            if(!prev.count(j)){
                nxa[i][j]=nb;
            }else {
                nxa[i][j] = prev[j];
                can[i].push_back(j);
            }
        }
    }

    for(int i=0;i<m;i++){
        int f,s;
        cin>>f>>s;
        while(f--){
            b.push_back(s);
        }
    }
    prev.clear();
    for(int i=mb-1;i>=0;i--){
        prev[b[i]]=i;
        for(int j=0;j<=k;j++){
            if(!prev.count(j)){
                nxb[i][j]=mb;
            }else {
                nxb[i][j] = prev[j];
            }
        }
    }
    for(int i=0;i<=nb;i++){
        dp[i][mb]=false;
    }
    for(int i=0;i<=mb;i++){
        dp[nb][i]=false;
    }
    auto cdp=&dp;
    bool fl=false;
    unordered_set<int> st;
    for(int i=nb-1;i>=0;i--){
        for(int j=mb-1;j>=0;j--){
            int cnt=0;
            if(!dp[i][j]) {
                for (auto elem: can[i]) {
                    int ni = nxa[i][elem], nj = nxb[j][elem];
                    if (ni >= nb || nj >= mb)continue;
                    cnt++;
                    if (!dp[ni + 1][nj + 1]) {
                        dp[i][j] = true;
                        break;
                    }
                    if(cnt>=80)break;
                }
            }
            if(a[i]==b[j] && !dp[i+1][j+1]){
                int mnj=-1;
                for(int vi=i;vi>=0;vi--){
                    for(int vj=j;vj>mnj;vj--){
                        if(a[vi]==b[vj] && a[vi]==a[i]){
                            mnj=max(mnj,vj);
                            break;
                        }
                        dp[vi][vj]=true;
                    }
                }
            }
        }
    }
    while(q--){
        int x,y;
        cin>>x>>y;
        if(dp[x][y]){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
}