#include <bits/stdc++.h>

#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<pair<int, int>>;
using vc = vector<char>;
using vb = vector<bool>;
template<typename T>
using ve = vector<T>;
template<typename T1, typename T2>
using pr = pair<T1, T2>;

const int INF = 1e9 + 1;
const long long INFLL = 1e18 + 1;
const int MOD = 1e9 + 7;

inline void fchmin(int &a, int &b) { a = min(a, b); }
inline void fchmax(int &a, int &b) { a = max(a, b); }

template<typename T>
inline bool chmin(T &a, T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
inline bool chmax(T &a, T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

// #include<ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// using oset = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

int reps = 1;


void solve() {
    int N, n; cin >> N >> n;
    int M, m; cin >> M >> m;
    int k, q; cin >> k >> q;
    vi a, b;
    for (int i = 0; i < n; i++) {
        int l, v; cin >> l >> v;
        while (l--) {
            a.push_back(v);
        }
    }
    for (int i = 0; i < m; i++) {
        int l, v; cin >> l >> v;
        while (l--) {
            b.push_back(v);
        }
    }

    ve<vb> dp(N, vb(M));
    bool f = false;
    for (int i = 0; i < N; i++) {
        if (a[i] == b.back()) f = true;
        dp[i][M - 1] = f;
    }
    f = false;
    for (int i = 0; i < M; i++) {
        if (b[i] == a.back()) f = true;
        dp[N - 1][i] = f;
    }
    for (int i = N - 2; i >= 0; i--) {
        vi el_was(k + 1, -1);
        vii el_pair(k + 1, {-1, -1});
        for (int j = N - 1; j >= i; j--) {
            if (a[j] == b.back()) {
                el_pair[a[j]] = {j, M - 1};
            }
            el_was[a[j]] = j;
        }
        int suff = 0;
        for (const auto &[x, y] : el_pair) {
            if (x != -1) suff += dp[x][y];
        }
        for (int j = M - 2; j >= 0; j--) {
            if (el_pair[b[j]].first != -1) {
                suff -= dp[el_pair[b[j]].first][el_pair[b[j]].second];
                el_pair[b[j]] = {el_pair[b[j]].first, j};
            } else if (el_was[b[j]] != -1) {
                el_pair[b[j]] = {el_was[b[j]], j};
                // suff += dp[el_pair[b[j]].first][el_pair[b[j]].second];
            }
            if (el_pair[b[j]].first > i) suff += dp[el_pair[b[j]].first][el_pair[b[j]].second];
            dp[i][j] = (suff > 0);
            if (a[i] == a[j] && !dp[i + 1][j + 1]) dp[i][j] = true;
            // cout << i << ' ' << j << ' ' << suff << ' ' << dp[i][j] << '\n';
            if (el_was[b[j]] != -1) {
                if (dp[el_was[b[j]]][j]) suff++;
            }
        }
    }
    
    while (q--) {
        int x, y; cin >> x >> y;
        cout << ((dp[x][y]) ? "Yes\n" : "No\n");
    }
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    cin >> reps;
    #endif

    for (int i = 1; i <= reps; i++) {
        #ifdef LOCAL
        cout << "===== Test #" << i << " ========\n";
        #endif
        solve();
        #ifdef LOCAL
        cout << "==== End test =====\n\n";
        #endif
    }
}