#ifndef LOCAL
#pragma GCC optimize("O3")
#endif

#include <bits/extc++.h>

using namespace std;
using namespace __gnu_pbds;
using oset = tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
using ll = long long;
const ll nMax = 5100;
bool dp[nMax][nMax];
int nxt1[nMax], nxt2[nMax];
bool canMove[nMax];
bool ans[nMax][nMax];
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin.tie(0)->sync_with_stdio(0);
    ll N, n, M, m, k, q;
    cin >> N >> n >> M >> m >> k >> q;
    vector<int> a, b;
    for (int i = 0; i < n; i++) {
        int l, v;
        cin >> l >> v;
        for (int i = 0; i < l; i++)a.push_back(v);
    }
    for (int i = 0; i < n; i++) {
        int l, v;
        cin >> l >> v;
        for (int i = 0; i < l; i++)b.push_back(v);
    }
    memset(nxt1, -1, sizeof nxt1);
    for (int j = N - 1; j >= 0; j--) {
        memset(nxt2, -1, sizeof nxt2);
        for (int i = M - 1; i >= 0; i--) {
            if (a[j] != b[i]) {
                nxt2[b[i]] = i;
                continue;
            }
            bool good = false;
            for(int kk = 1; kk <=k; kk++){
                if(nxt1[kk] != -1 && nxt2[kk] != -1 && !dp[nxt1[kk]][nxt2[kk]])good = true;
            }
            if(good)dp[j][i] = 1;
            nxt2[b[i]]=i;
        }
        nxt1[a[j]] = j;
    }
    memset(nxt1, -1, sizeof nxt1);
    for (int j = N - 1; j >= 0; j--) {
        nxt1[a[j]] = j;
        memset(nxt2, -1, sizeof nxt2);
        for (int i = M - 1; i >= 0; i--) {
            nxt2[b[i]] = i;
            if (a[j] != b[i])continue;
            for(int kk = 1; kk <=k; kk++){
                    if(nxt1[kk] != -1 && nxt2[kk] != -1 && !dp[nxt1[kk]][nxt2[kk]])ans[j][i]=true;
            }
        }
    }
    for(int i = 0; i < q; i++){
        int l,r;
        cin >> l >> r;
        cout << (ans[l][r] ? "Yes" : "No") << '\n';
    }
}