#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

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

bool dp[5005][5005];
int a[5005], b[5005];
int nxt_a[5005][1605], nxt_b[5005][1605];
bool final_dp[5005][5005];

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

	int N, n, M, m, k, q;
	cin >> N >> n >> M >> m >> k >> q;
	int last;

	last = 0; 
	for (int i = 0; i < n; ++i) {
		int l, v;
		cin >> l >> v;
		for (int j = 0; j < l; ++j) {
			a[last++] = v;
		}
	}

	last = 0;
	for (int i = 0; i < m; ++i) {
		int l, v;
		cin >> l >> v;
		for (int j = 0; j < l; ++j) {
			b[last++] = v;
		}
	}

	for (int i = N - 1; i >= 0; --i) {
		for (int j = 1; j <= k; ++j) {
			if (i + 1 < N && a[i + 1] == j) {
				nxt_a[i][j] = i + 1;
			} else {
				if (i + 1 < N) {
					nxt_a[i][j] = nxt_a[i + 1][j];
				} else {
					nxt_a[i][j] = -1;
				}
			}
		}
	}

	for (int i = M - 1; i >= 0; --i) {
		for (int j = 1; j <= k; ++j) {
			if (i + 1 < M && b[i + 1] == j) {
				nxt_b[i][j] = i + 1;
			} else {
				if (i + 1 < M) {
					nxt_b[i][j] = nxt_b[i + 1][j];
				} else {
					nxt_b[i][j] = -1;
				}
			}
		}
	}

	for (int i = N - 1; i >= 0; --i) {
		for (int j = M - 1; j >= 0; --j) {
			if (a[i] ^ b[j]) continue;
			dp[i][j] = 1;
			for (int t = 1; t <= k; ++t) {
				if (nxt_a[i][t] == -1 || nxt_b[j][t] == -1) {
					continue;
				} else if (dp[nxt_a[i][t]][nxt_b[j][t]]) {
					dp[i][j] = 0;
					break;
				}
			}
		}
	}
	for (int x = 0; x < N; ++x) {
		for (int y = 0; y < M; ++y) {
			if (a[x] ^ b[y]) continue;
			bool res = dp[x][y];
			for (int s = 1; s <= k; ++s) {
				if (s == a[x]) continue;
				if (nxt_a[x][s] != -1 && nxt_b[y][s] != -1 && dp[nxt_a[x][s]][nxt_b[y][s]]) {
					res = true;
					break;
				}
			}
			final_dp[x][y] = res;
		}
	}
	while (q--) {
		int x, y;
		cin >> x >> y;
		
		cout << (final_dp[x][y] ? "Yes\n" : "No\n");
	}
}
