#ifdef LOCAL
#pragma optimize("", off)
#include "localstd1.h"
#else
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/allocator.h>
#pragma GCC target("avx2,bmi,bmi2")
#include <bits/stdc++.h>
#endif

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define all(a) (a).begin(), (a).end()

vector<int> read(int n) {
	int cnt = 0;
	vector<int> res;
	for (int i = 0; i < n; i++) {
		int len, val; cin >> len >> val;
		while (len--) res.push_back(val - 1);
	}
	return res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int N, n, M, m, k, q; cin >> N >> n >> M >> m >> k >> q;
	vector<int> a = read(n), b = read(m);
	const int MAXN = 5001; //1601
	pair<bool, bool> dp[MAXN][MAXN];

	vector<bool> is_win(k, true);
	int cntl = 0;

	vector<vector<int>> stacki(k), stackj(k);

	n = a.size(); m = b.size();
	for (int i = n - 1; i >= 0; i--) {
		for (int j = m - 1; j >= 0; j--) {
			dp[i][j].first = cntl;
			dp[i][j].second = cntl == 1 && !is_win[b[j]];
			stackj[b[j]].push_back(j);
			if (stacki[b[j]].size()) {
				int ind = stacki[b[j]].back();

				cntl -= is_win[a[ind]] == false;
				is_win[a[ind]] = dp[ind][j].first;
				cntl += is_win[a[ind]] == false;
			}
		}

		is_win.assign(k, true);
		cntl = 0;
		stackj.assign(k, {});
		stacki[a[i]].push_back(i);
	}

	while (q--) {
		int x, y; cin >> x >> y;
		cout << (!dp[x][y].first && !dp[x][y].second ? "Yes" : "No") << '\n';
	}
	
	return 0;
}