#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <limits>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;
using pii = pair<int, int>;
using pli = pair<long long, int>;
using pil = pair<int, long long>;
using pll = pair<long long, long long>;
template <typename T>
using uset = unordered_set<T>;
template <typename T1, typename T2>
using umap = unordered_map<T1, T2>;

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

inline void solve() {
	int N, n, M, m, k, q;
	cin >> N >> n >> M >> m >> k >> q;
	vector<int> a(N), b(M);
	int ptr = 0;
	for (int i = 0; i < n; i++) {
		int l, v;
		cin >> l >> v;
		v--;
		while (l--)
			a[ptr++] = v;
	}
	ptr = 0;
	for (int i = 0; i < m; i++) {
		int l, v;
		cin >> l >> v;
		v--;
		while (l--)
			b[ptr++] = v;
	}
	vector<vector<bool>> dp(N, vector<bool>(M));
	vector<vector<int>> nxt_a(N, vector<int>(k, N));
	vector<vector<int>> nxt_b(M, vector<int>(k, M));
	for (int i = N - 2; i > -1; i--)
		for (int v = 0; v < k; v++) {
			if (a[i + 1] == v)
				nxt_a[i][v] = i + 1;
			else
				nxt_a[i][v] = nxt_a[i + 1][v];
		}
	for (int i = M - 2; i > -1; i--)
		for (int v = 0; v < k; v++) {
			if (b[i + 1] == v)
				nxt_b[i][v] = i + 1;
			else
				nxt_b[i][v] = nxt_b[i + 1][v];
		}
	for (int i = N - 1; i > -1; i--)
		for (int j = M - 1; j > -1; j--)
			if (a[i] == b[j]) {
				for (int v = 0; v < k; v++)
					if (nxt_a[i][v] != N && nxt_b[j][v] != M)
						if (!dp[nxt_a[i][v]][nxt_b[j][v]])
							dp[i][j] = 1;
			}
	vector<int> suf_max(N, -1);
	for (int i = 0; i < N; i++)
		for (int j = 0; j < M; j++)
			if (dp[i][j] && a[i] == b[j])
				suf_max[i] = j;
	while (q--) {
		int x, y;
		cin >> x >> y;
		bool ans = false;
		for (int v = 0; v < k; v++) {
			int i, j;
			if (a[x] == v)
				i = x;
			else
				i = nxt_a[x][v];
			if (b[y] == v)
				j = y;
			else
				j = nxt_b[y][v];
			if (i < N && j < M && !dp[i][j])
				ans = true;
		}
		if (ans)
			cout << "Yes\n";
		else
			cout << "No\n";
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
#ifdef _DEBUG
	freopen("01.dat", "r", stdin);
#endif
	int tt = 1;
#ifdef _DEBUG
	cin >> tt;
#endif
	for (int test_id = 1; test_id <= tt; test_id++) {
#ifdef _DEBUG
		cout << "TESTCASE# " << test_id << '\n';
#endif
		solve();
	}
	return 0;
}
