//author: лелутик :3
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <time.h>
#include <cmath>
#include <cassert>
#include <random>
using namespace std;
#define line cout << "\n"
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define ppb pop_back
#define sz(a) (int) a.size()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pii pair<int, int>
const int MAXN = 1e5 + 1;
unordered_map<int, unordered_map<int, int>> dp;
int a[MAXN];
int b[MAXN];
int N, M;
int K;
const int C = 1601;
vector<int> posa[C];
vector<int> posb[C];


void dfs(int i, int j) {
    if (dp[i][j]) {
        return;
    }
    vector<pii> trans;
    for (int k = 1; k <= K; k++) {
        auto fora = lower_bound(all(posa[k]), i);
        auto forb = lower_bound(all(posb[k]), j);
        if (fora == posa[k].end() || forb == posb[k].end()) {
            continue;
        }
        trans.pb({*fora + 1, *forb + 1});
    }
    int f = 0;
    for (auto &u : trans) {
        dfs(u.first, u.second);
        if (dp[u.first][u.second] == 1) {
            f = 1;
        }
    }
    dp[i][j] = f + 1;
}

void solve() {
    int n, m, q;
    cin >> N >> n >> M >> m >> K >> q;
    int idx = 0;
    for (int i = 0; i < n; i++) {
        int l, v;
        cin >> l >> v;
        while (l--) {
            a[idx] = v;
            posa[v].pb(idx);
            idx++;
        }
    }
    idx = 0;
    for (int i = 0; i < m; i++) {
        int l, v;
        cin >> l >> v;
        while (l--) {
            b[idx] = v;
            posb[v].pb(idx);
            idx++;
        }
    }
    while (q--) {
        int a, b;
        cin >> a >> b;
        dfs(a, b);
        if (dp[a][b] == 1) {
            cout << "No"; line;
        } else {
            cout << "Yes"; line;
        }
    }
}

signed main() {
    fast;


#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif


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