#ifdef LOCAL
#define _GLIBCXX_DEBUG
#define debug(x) cerr << __LINE__ << ": " << (#x) << " = " << (x) << endl
#else
#define debug(...) 42
#endif

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
// #pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef __int128 LL;
#define all(x) (x).begin(), (x).end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T>
istream &operator >>(istream &in, vector<T> &a) {
    for (auto &elem : a) {
        in >> elem;
    }
    return in;
}

template<typename T>
ostream &operator <<(ostream &out, const vector<T> &a) {
    for (const auto &elem : a) {
        out << elem << ' ';
    }
    return out;
}

int n, m, k, q;
vector<int> a, b;

bool dp[300][300][1601];
bool used[300][300][1601];

bool get(int i, int j, int val) {
    if (i >= n || j >= m) {
        return false;
    }
    if (used[i][j][val]) {
        return dp[i][j][val];
    }
    used[i][j][val] = true;
    if (a[i] == val && b[j] == val) {
        for (int c = 1; c <= k; ++c) {
            dp[i][j][val] |= !get(i + 1, j + 1, c);
        }
        return dp[i][j][val];
    }
    if (a[i] != val) {
        return dp[i][j][val] = get(i + 1, j, val);
    }
    return dp[i][j][val] = get(i, j + 1, val);
}

void solve() {
    while (q--) {
        int x, y;
        cin >> x >> y;
        bool ok = false;
        for (int c = 1; c <= k; ++c) {
            ok |= get(x, y, c);
        }
        cout << (ok ? "Yes\n" : "No\n");
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n1, m1;
    cin >> n >> n1 >> m >> m1 >> k >> q;
    while (n1--) {
        int l, v;
        cin >> l >> v;
        while (l--) {
            a.push_back(v);
        }
    }
    while (m1--) {
        int l, v;
        cin >> l >> v;
        while (l--) {
            b.push_back(v);
        }
    }
    solve();
}