#include<iostream>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<random>
#include<chrono>

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define int long long


signed main() {
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    cout.precision(20);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int N, n, M, m, k, q;
    cin >> N >> n >> M >> m >> k >> q;
    vector<int> f, s;
    for (int i = 0; i < n; ++i) {
        int l, v;
        cin >> l >> v;
        for (int _ = 0; _ < l; _++) {
            f.push_back(v);
        }
    }
    for (int i = 0; i < m; ++i) {
        int l, v;
        cin >> l >> v;
        for (int _ = 0; _ < l; _++) {
            s.push_back(v);
        }
    }
    n = (int)f.size(), m = (int)s.size();
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            dp[i][j] = 1;
            dp[i][j] &= (dp[i - 1][j - 1]);
            int ps = m - j;
            while (ps != m && s[ps] != f[n - i]) {
                ps++;
            }
            if (ps != m) {
                dp[i][j] &= dp[i - 1][m - (ps + 1)];
            }
            
            ps = n - i;
            while (ps != n && f[ps] != s[m - j]) {
                ps++;
            }
            if (ps != n) {
                dp[i][j] &= dp[n - (ps + 1)][j - 1];
            }
            dp[i][j] = (dp[i][j] ^ 1);
        }
    }
    while (q--) {
        int x, y;
        cin >> x >> y;
        if (dp[n - x][m - y]) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
}