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

using namespace std;


struct e{
    int leftt;
    int right;
    int ind;
};



const int inf = 1e9 + 7;
const int maxn = 5000 + 10;
const int maxk = 1600 + 10;
const int wow = 29;
vector<vector<pair<int, int>>> lst(2, vector<pair<int, int>>());
vector<vector<vector<vector<int> > > > dp(wow, vector<vector<vector<int> > >(wow, vector<vector<int> >(maxk, vector<int>(maxk, -1))));
vector<vector<vector<int>>> next_interval(2, vector<vector<int>>(maxk, vector<int>(maxk, inf)));
vector<vector<vector<e>>> from_symv_to_interval(2, vector<vector<e>>(maxk, vector<e>()));
vector<int> siz_lst(2, 0);
int all_n, n, all_m, m, k, q;


void make_interval() {
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < siz_lst[i]; j++) {
            for (int u = j + 1; u < siz_lst[i]; u++) {
                next_interval[i][lst[i][u].second][j] = min(next_interval[i][lst[i][u].second][j], u);
            }
        }
    }
}



void make_dp(int ost_a, int ost_b, int a, int b) {
    if (dp[ost_a][ost_b][a][b] != -1) {
        return;
    }
    vector<vector<int>> maybe;
    for (int symv = 1; symv <= k; symv++) {
        int ind_a = next_interval[0][symv][a];
        int ind_b = next_interval[1][symv][b];
        int new_ost_a, new_ost_b;
        if (ind_a != inf) {
            if (lst[0][ind_a].first - 1 < wow) {
                new_ost_a = lst[0][ind_a].first - 1;
            } else if (lst[0][ind_a].first % 2 == 1) {
                new_ost_a = wow - 1;
            } else {
                new_ost_a = wow - 2;
            }
        }
        if (ind_b != inf) {
            if (lst[1][ind_b].first - 1 < wow) {
                new_ost_b = lst[1][ind_b].first - 1;
            } else if (lst[1][ind_b].first % 2 == 1) {
                new_ost_b = wow - 1;
            } else {
                new_ost_b = wow - 2;
            }
        }
        if (symv != lst[0][a].second) {
            if (ind_a != inf && ind_b != inf) {
                maybe.push_back({new_ost_a, new_ost_b, ind_a, ind_b});
            }
        } else {
            if (ost_a == 0 && ost_b == 0 && ind_a != inf && ind_b != inf) {
                maybe.push_back({new_ost_a, new_ost_b, ind_a, ind_b});
            }
            if (ost_a != 0 && ost_b == 0 && ind_b != inf) {
                maybe.push_back({ost_a - 1, new_ost_b, a, ind_b});
            }
            if (ost_a == 0 && ost_b != 0 && ind_a != inf) {
                maybe.push_back({new_ost_a, ost_b - 1, ind_a, b});
            }
            if (ost_a != 0 && ost_b != 0) {
                maybe.push_back({ost_a - 1, ost_b - 1, a, b});
            }
        }
    }
    for (auto pai : maybe) {
        make_dp(pai[0], pai[1], pai[2], pai[3]);
        if (dp[pai[0]][pai[1]][pai[2]][pai[3]] == 0) {
            dp[ost_a][ost_b][a][b] = 1;
            return;
        }
    }
    if (dp[ost_a][ost_b][a][b] == -1) {
        dp[ost_a][ost_b][a][b] = 0;
    }
}

pair<int, int> find_near(int ind, int symv, int x) {
    for (auto pai : from_symv_to_interval[ind][symv]) {
        int l = pai.leftt;
        int r = pai.right;
        int a = pai.ind;
        if (r >= x) {
            int real_l;
            if (l >= x) {
                real_l = l;
            } else {
                real_l = x;
            }
            int elem = (r - real_l + 1);
            int ost;
            if (elem - 1 < wow) {
                ost = elem - 1;
            } else if (elem % 2 == 1) {
                ost = wow - 1;
            } else {
                ost = wow - 2;
            }
            return {a, ost};
        }
    }
    return {inf, inf};
}




signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
    cin >> all_n >> n >> all_m >> m >> k >> q;
    siz_lst[0] = n;
    siz_lst[1] = m;
    int start = 0;
    for (int i = 0; i < n; i++) {
        int siz, symv;
        cin >> siz >> symv;
        lst[0].push_back({siz, symv});
        from_symv_to_interval[0][symv].push_back({start, start + siz - 1, i});
        start += siz;
    }
    start = 0;
    for (int i = 0; i < m; i++) {
        int siz, symv;
        cin >> siz >> symv;
        lst[1].push_back({siz, symv});
        from_symv_to_interval[1][symv].push_back({start, start + siz - 1, i});
        start += siz;
    }
    make_interval();
    for (; q > 0; --q) {
        int x, y;
        cin >> x >> y;
        bool check_alice_won = false;
        for (int symv = 1; symv <= k; symv++) {
            pair<int, int> a = find_near(0, symv, x);
            pair<int, int> b = find_near(1, symv, y);
            if (a.first != inf && b.first != inf) {
                make_dp(a.second, b.second, a.first, b.first);
                if (dp[a.second][b.second][a.first][b.first] == 0) {
                    check_alice_won = true;
                }
            }
        }
        if (check_alice_won) {
            cout << "Yes" << '\n';
        } else {
            cout << "No" << '\n';
        }
    }
}
