#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <string>

#define len(v) (int)((v).size())
#define ss second
#define ff first


typedef long long ll;

using namespace std;

void solve() {
	int N, n, M, m, k, q;
	cin >> N >> n >> M >> m >> k >> q;

	vector<int> a, b;
	for (int i = 0; i < n; ++i) {
		int li, vi;
		cin >> li >> vi;

		while (li--) {
			a.push_back(vi);
		}
	}
	for (int i = 0; i < m; ++i) {
		int li, vi;
		cin >> li >> vi;

		while (li--) {
			b.push_back(vi);
		}
	}

	vector<map<int, int>> lsa(N + 1);
	vector<map<int, int>> lsb(M + 1);

	vector<map<int, int>> nxa(N + 1), nxb(M + 1);

	vector<vector<bool>> dp(N + 1, vector<bool>(M + 1, false));


	set<int> vls;
	for (int i = 0; i < N; ++i) {
		vls.insert(a[i]);
	}
	for (int i = 0; i < M; ++i) {
		vls.insert(b[i]);
	}

	for (int i = N - 1; i >= 0; --i) {
		lsa[i] = lsa[i + 1];
		lsa[i][a[i]] = i;

		nxa[i] = nxa[i + 1];
		for (int j : vls) {
			if (a[i] != j) {
				nxa[i][j] = i;
			}
		}
	}

	for (int i = M - 1; i >= 0; --i) {
		lsb[i] = lsb[i + 1];
		lsb[i][b[i]] = i;

		nxb[i] = nxb[i + 1];
		for (int j : vls) {
			if (b[i] != j) {
				nxb[i][j] = i;
			}
		}
	}

	for (int i = N - 1; i >= 0; --i) {
		for (int j = M - 1; j >= 0; --j) {
			if (lsb[j].find(a[i]) != lsb[j].end()) {
				dp[i][j] = dp[i][j] || (!dp[i + 1][lsb[j][a[i]] + 1]);
			}
			if (nxa[i].find(a[i]) != nxa[i].end()) {
				dp[i][j] = dp[i][j] || dp[nxa[i][a[i]]][j];
			}
			if (nxb[j].find(b[j]) != nxb[j].end()) {
				dp[i][j] = dp[i][j] || dp[i][nxb[j][b[j]]];
			}
		}
	}

	for (int i = 0; i < q; ++i) {
		int x, y;
		cin >> x >> y;

		if (dp[x][y]) {
			cout << "Yes\n";
		}
		else {
			cout << "No\n";
		}
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout.precision(30);

	int t = 1;
 //   cin >> t;
	while (t--) solve();
}



