#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N, n, M, m, k, q;
    cin >> N >> n >> M >> m >> k >> q;
    vector<int> a, b; a.reserve(N+1); b.reserve(M+1);
    for (int i = 0; i < n; ++i) {
        int l, v; cin >> l >> v;
        while (l--) a.emplace_back(v);
    }
    a.emplace_back(0);
    for (int i = 0; i < m; ++i) {
        int l, v; cin >> l >> v;
        while (l--) b.emplace_back(v);
    }
    b.emplace_back(0);
    vector<vector<bitset<16>>> v(N+1, vector<bitset<16>>(M+1));
    for (int i = N-1; i>=0; --i) {
        for (int j = M-1; j>=0; --j) {
            if (a[i]!=b[j]) {
                bool s = v[i+1][j][a[i]-1];
                v[i+1][j][a[i]-1] = false;
                v[i][j] |= v[i+1][j];
                v[i+1][j][a[i]-1] = s;

                s = v[i][j+1][b[j]-1];
                v[i][j+1][b[j]-1] = false;
                v[i][j] |= v[i][j+1];
                v[i][j+1][b[j]-1] = s;
            } else {
                v[i][j] |= v[i+1][j]|v[i][j+1];
                v[i][j].set(a[i]-1, v[i+1][j+1].none());
            }
        }
    }
    while (q--) {
        int x, y; cin >> x >> y;
        cout << (v[x][y].any()?"Yes":"No") << endl;
    }

    return 0;
}
