#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

auto seed = std::chrono::steady_clock::now().time_since_epoch().count();
mt19937 rnd(seed);

using ll = long long;

//#define int ll

using vi = vector<int>;
using pii = pair<int, int>;
using vp = vector<pair<int, int>>;

template<class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

int read_int() {
    int a = 0;
    char c = getchar();
    while (c < '0' || c > '9') {
        c = getchar();
    }
    while ('0' <= c && c <= '9') {
        a *= 10;
        a += c - '0';
        c = getchar();
    }
    return a;
}

void solve() {
    int n, N, m, M, k, q;
    cin >> N >> n >> M >> m >> k >> q;
    vi a, b;
    vp a2, b2;
    vector<vi> nexta(N, vi(k, -1));
    vector<vi> nextb(M, vi(k, -1));
    vi pos(k, 0);
    int idx = 0;
    for (int i = 0; i < n; ++i) {
        int l, v;
        cin >> l >> v;
        v--;
        for (int j = 0; j < l; ++j) {
            a.push_back(v);
            for (int j = pos[v]; j < idx; ++j) {
                nexta[j][v] = idx;
            }
            pos[v] = idx;
            idx++;
        }
        a2.push_back({l, v});
    }
    std::fill(pos.begin(), pos.end(), 0);
    idx = 0;
    for (int i = 0; i < m; ++i) {
        int l, v;
        cin >> l >> v;
        v--;
        for (int j = pos[v]; j < i; ++j) {
            nextb[j][v] = i;
        }
        pos[v] = i;
        for (int j = 0; j < l; ++j) {
            b.push_back(v);
            for (int j = pos[v]; j < idx; ++j) {
                nextb[j][v] = idx;
            }
            pos[v] = idx;
            idx++;
        }
        b2.push_back({l, v});
    }
    vector<vi> dp(N, vi(M));
    for (int i = N - 1; i >= 0; i--) {
        for (int j = M - 1; j >= 0; j--) {
            if (a[i] != b[j]) {
//                dp[i][j] = 1;
                continue;
            }

            int cnt = 0;
            for (int v = 0; v < k; ++v) {
                if (nexta[i][v] == -1 || nextb[j][v] == -1) {
                    continue;
                }

                cnt++;
                if (dp[nexta[i][v]][nextb[j][v]] == 0) {
                    dp[i][j] = 1;
                    break;
                }
            }
//            if(cnt == 0){
//                dp[i][j] = 0
//            }
        }
    }
    for (int i = 0; i < q; ++i) {
        int x, y;
        cin >> x >> y;
        int can = dp[x][y];

        for (int v = 0; v < k; ++v) {
            if (nexta[x][v] == -1 || nextb[y][v] == -1) {
                continue;
            }
            if (dp[nexta[x][v]][nextb[y][v]] == 0) {
                can = 1;
                break;
            }
        }
        if (can == 0) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
}


signed main() {
#ifdef LOCAL
    freopen(R"(C:\work\untitled\input.txt)", "r", stdin);
    freopen("C:\\work\\untitled\\output.txt", "w", stdout);
    auto start = std::chrono::steady_clock::now();
#else
    cin.tie();
    cout.tie();
    ios_base::sync_with_stdio(0);
#endif
    int t_ = 1;
    //cin>>t;
    while (t_--) {
        solve();
    }

#ifdef LOCAL
    auto end = std::chrono::steady_clock::now();
    cout << "\n======\n";
    cout << chrono::duration_cast<chrono::milliseconds>(end - start);
#endif
}
