//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 int long long
#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 = 5e3 + 1;
int dp[MAXN][MAXN];
int a[MAXN];
int b[MAXN];
vector<pii> g[MAXN][MAXN];
int N, M;


void dfs(int i, int j) {
    if (dp[i][j]) {
        return;
    }
    unordered_map<int, int> have;
    for (int k = i; k < N; k++) {
        if (have.find(a[k]) == have.end()) {
            have[a[k]] = k;
        }
    }
    for (int k = j; k < M; k++) {
        if (have.find(b[k]) == have.end()) {
            continue;
        }
        int pos = have[b[k]];
        g[i][j].pb({pos + 1, k + 1});
        have.erase(b[k]);
    }
    int f = 0;
    for (auto &u : g[i][j]) {
        dfs(u.first, u.second);
        if (dp[u.first][u.second] == 1) {
            f = 1;
        }
    }
    dp[i][j] = f + 1;
}

void solve() {
    int n, m, k, 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;
            idx++;
        }
    }
    idx = 0;
    for (int i = 0; i < m; i++) {
        int l, v;
        cin >> l >> v;
        while (l--) {
            b[idx] = v;
            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();
    }
}