#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define siz(x) int(x.size())
#define ceil(a, b) (((a) + (b) - 1) / (b))
const int INF = 2e9 + 7;
const ll LINF = 1e18 + 7;
const int mxN = 5e3 + 10;

struct Fenwick {
    int n, m;
    vector<vector<int>> tree;
    Fenwick(int n, int m) : n(n), m(m) {
        tree.resize(n, vector<int>(m));
    }

    ll query1(int i, int j_) {
        ll ans = 0;
        for(; i >= 0; i = (i & (i + 1)) - 1) {
            for(int j = j_; j >= 0; j = (j & (j + 1)) - 1) ans += tree[i][j];
        }
        return ans;
    }
    bool query(int i, int j) {
        return query1(n - 1, m - 1) - query1(n - 1, j - 1) - query1(i - 1, m - 1) + query1(i - 1, j - 1);
    }

    void update(int i, int j_, int val) {
        for(; i < n; i |= i + 1) {
            for(int j = j_; j < m; j |= j + 1) tree[i][j] += val;
        }
    }
    void update(int u, int l, int d, int r) {
        update(d, r, 1);
        if(l && u) update(u - 1, l - 1, -1);
    }
};

int N, n, M, m, k, q, dp[mxN][mxN];
void solve() {
    cin >> N >> n >> M >> m >> k >> q;
    vector<int> a, b, ptra(k + 1, -1), ptrb(k + 1, -1);
    vector<vector<int>> inda(k + 1), indb(k + 1);
    for(int i = 0; i < n; ++i) {
        int l, x;
        cin >> l >> x;
        for(int j = 0; j < l; ++j) {
            a.push_back(x);
            inda[x].push_back(siz(a) - 1);
        }
    }
    for(int i = 0; i < m; ++i) {
        int l, x;
        cin >> l >> x;
        for(int j = 0; j < l; ++j) {
            b.push_back(x);
            indb[x].push_back(siz(b) - 1);
        }
    }
    Fenwick fwt(N + 1, M + 1);
    for(int i = N - 1; i >= 0; --i) {
        int x = a[i];
        while(ptra[x] + 1 < siz(inda[x]) && inda[x][ptra[x] + 1] < i) ptra[x]++;
        ptrb[x] = -1;
        for(int j = M - 1; j >= 0; --j) {
            if(fwt.query(i, j)) dp[i][j] = 1;
            if(a[i] == b[j] && (i + 1 == N || j + 1 == M || !dp[i + 1][j + 1])) dp[i][j] = 1;
            if(dp[i][j] && a[i] == b[j]) {
                while(ptrb[x] + 1 < siz(indb[x]) && indb[x][ptrb[x] + 1] < j) ptrb[x]++;
                int pi = (ptra[x] >= 0 ? inda[x][ptra[x]] : -1), pj = (ptrb[x] >= 0 ? indb[x][ptrb[x]] : -1);
                if(pi + 1 <= i - 1 && pj + 1 <= j - 1)
                    fwt.update(pi + 1, pj + 1, i - 1, j - 1);
            }
        }
    }
    for(int _ = 0; _ < q; ++_) {
        int x, y;
        cin >> x >> y;
        cout << (dp[x][y] ? "Yes\n" : "No\n");
    }
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cout << fixed; cout.precision(8);
#ifdef INEYOK
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();
}
