#pragma GCC optimize("O3")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <immintrin.h>
#include <numeric>
#include <queue>
#include <map>

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

#define unused(x) (void)x
#define used(x) (x)
#define temp(x) tmp_##x

struct trie
{
	map<int, trie*> go;
	vector <int> evidence;
	vector <bool> ans;
} *A, * B;

void calc(trie* root, trie* cur)
{
	if (cur == NULL)
	{
		root->ans.assign(root->evidence.size(), true);
		for (auto& i : root->go)
		{
			calc(i.second, cur);
		}
		return;
	}
	for (auto& i : root->go)
	{
		calc(i.second, cur->go[i.first]);
	}
	int k = root->evidence.size();
	root->ans.assign(k, false);
	for (size_t i = 0; i < k; i++)
	{
		for (auto& j : root->go)
		{
			auto it = lower_bound(j.second->evidence.begin(), j.second->evidence.end(), root->evidence[i]);
			if (it != j.second->evidence.end() && !j.second->ans[it - j.second->evidence.begin()])
			{
				root->ans[i] = true;
				break;
			}
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ooshp 2024-2025 zakluchitelnuy tur
	// Code is written by Mark_Pr (c) 2025
	A = new trie();
	B = new trie();
	int N, n, M, m, k, q;
	cin >> N >> n >> M >> m >> k >> q;
	unused(N);
	unused(M);
	unused(k);
	vector <int> pr1(1), pr2(1);
	vector <int> c1, c2;
	vector <int> s1, s2;
	vector <int> f;
	for (size_t i = 0; i < n; i++)
	{
		int x, d;
		cin >> x >> d;
		pr1.push_back(pr1.back() + x);
		c1.push_back(d);
		for (size_t j = 0; j < x; j++)
		{
			s1.push_back(d);
		}
		f.push_back(d);
		//c2.push_back(d);
	}
	for (size_t i = 0; i < m; i++)
	{
		int x, d;
		cin >> x >> d;
		pr2.push_back(pr2.back() + x);
		c2.push_back(d);
		for (size_t j = 0; j < x; j++)
		{
			s2.push_back(d);
		}
	}
#ifdef _DEBUG
	cout << "s1 = ";
	for (auto& i : s1)
	{
		cout << i << ' ';
	}
	cout << "\ns2 = ";
	for (auto& i : s2)
	{
		cout << i << ' ';
	}
	cout << '\n';
#endif
	//vector <vector<pair<int, int>>> cache(s2.size());
	//vector <bool> ans(q);
	//for (size_t i = 0; i < q; i++)
	//{
	//	int a, b;
	//	cin >> a >> b;
	//	cache[b].emplace_back(a, i);
	//}
	////vector <int> msz(s1.size());
	//for (size_t i = 0; i < s1.size(); i++)
	//{
	//	trie* t = A;
	//	for (int j = i; j < s1.size(); j++)
	//	{
	//		t->evidence.push_back(i);
	//		t->ans.push_back(false);
	//		if (t->go[s1[j]] == NULL)
	//			t->go[s1[j]] = new trie();
	//		t = t->go[s1[j]];
	//	}
	//	t->ans.push_back(false);
	//	t->evidence.push_back(i);
	//}
	//for (int i = s2.size() - 1; i >= 0; i--)
	//{
	//	trie* t = B;
	//	for (int j = i; j < s2.size(); j++)
	//	{
	//		if (t->go[s2[j]] == NULL)
	//			t->go[s2[j]] = new trie();
	//		t = t->go[s2[j]];
	//	}
	//	/*for (size_t i = 0; i < s1.size(); i++)
	//	{
	//		msz[i] = 0;
	//		t = B;
	//		int j = 0;
	//		while (j < s1.size() && t != NULL)
	//		{
	//			t = t->go[s1[j]];
	//			j++;
	//			msz[i]++;
	//		}
	//	}*/
	//	calc(A, B);
	//	for (auto& j : cache[i])
	//	{
	//		ans[j.second] = A->ans[j.first];
	//	}
	//}
	//for (auto i : ans)
	//{
	//	if (i)
	//		cout << "Yes";
	//	else
	//		cout << "No";
	//	cout << '\n';
	//}
	sort(f.begin(), f.end());
	f.resize(unique(f.begin(), f.end()) - f.begin());
	vector <vector <bool>> dp(s1.size(), vector<bool>(s2.size()));
	int q1 = s1.size(), q2 = s2.size();
	for (int i = q1 - 1; i >= 0; i--)
	{
		for (int j = q2 - 1; j >= 0; j--)
		{
			if (s1[i] != s2[j])
			{
				dp[i][j] = false;
				continue;
			}
			dp[i][j] = true;
			set <int> nums;
			for (int t = i + 1; t < q1; t++)
			{
				if (nums.count(s1[t]))
					continue;
				int t2 = find(s2.begin() + j + 1, s2.end(), s1[t]) - s2.begin();
				nums.insert(s1[t]);
				if (t2 != q2 && dp[t][t2])
				{
					dp[i][j] = false;
					break;
				}
			}
		}
	}
#ifdef _DEBUG

#endif
	vector <vector <bool>> ans(q1, vector<bool>(q2));
	for (int i = q1 - 1; i >= 0; i--)
	{
		for (int j = q2 - 1; j >= 0; j--)
		{
			ans[i][j] = dp[i][j];
			auto it = upper_bound(pr1.begin(), pr1.end(), i);
			if (*it != q1 && ans[*it][j])
				ans[i][j] = true;
			it = upper_bound(pr2.begin(), pr2.end(), j);
			if (*it != q2 && ans[i][*it])
				ans[i][j] = true;
		}
	}
	for (size_t i = 0; i < q; i++)
	{
		int x, y;
		cin >> x >> y;
		if (ans[x][y])
			cout << "Yes";
		else
			cout << "No";
		cout << '\n';
	}
	return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
