#include<bits/stdc++.h>

#define X first
#define Y second
#define eb push_back
#define pb pop_back
#define siz(a) int(a.size())
//for traversing the container (bcoz we cannot access linked list etc with direct index)
//c stands for container and it for iterator
#define tr(c, it) \
		for(typeof(c.begin()) it=c.begin() ; it != c.end() ; it++)

#define all(c) c.begin(), c.end()
#define present(container, element) (container.find(element) != container.end()) //whether the element is present in the container

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define scan(x) scanf("%lld", &x)
#define print(x) printf("%lld", x)
#define pN printf("\n");
using namespace std;

typedef long long int ll;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef vector < ll > vll;
typedef vector < vll > vvll;

typedef pair < int , int > ii;

const int mod=1e9+7;
const int maxn=2e5+50;

ll arr[maxn], n;

ll find(ll root){

	if(root == arr[root])
		return root ;

	return arr[root] = find(arr[root]);
}

ll join(ll root1,ll root2, ll type){

	ll loveA = find(root1);
	ll loveB = find(root2);
	ll hateA = find(root1+n);
	ll hateB = find(root2+n);

	if(type == 1){
		if(loveA == hateB)
			return 0;

		if(loveA != loveB)
			arr[loveA] = loveB;
		if(hateA != hateB)
			arr[hateA] = hateB;

		return 1;
	} else{

		if(loveA == loveB )
			return 0;

		if(loveA != hateB)
			arr[loveA] = hateB;

		if(hateA != loveB)
			arr[hateA] = loveB;

		return 1;
	}

}
map<string, int > mp;
int main()
{
	ios_base::sync_with_stdio(0);

	ll m, q, ch, check, root1, root2, i;

	cin >> n >> m >> q;

	string str, str1, str2;

	//inititialize(n);

	for(i=1; i<=n; i++)
	{
		cin >> str;

		mp[str]=i;

		arr[i]=i;
		arr[i+n]=i+n;
	}
	//map<string, ll> :: iterator it=mp.begin();
	while(m--){
		cin >> ch >> str1 >> str2;
		root1 = mp[str1];
		root2 = mp[str2];

		check=join(root1, root2, ch);

		//trace3(check, root1, root2);

		if(check==1)
			cout << "YES\n";
		else
			cout << "NO\n";

	//	for(i=1; i<=n; i++)
			//trace3(i, hate[i], love[i]);
	}

	while(q--) {
		cin >> str1 >> str2;

		root1 = mp[str1];
		root2 = mp[str2];

		//root1L = find_love(root1);
		//root2L = find_love(root2);

		if(	find(root1) == find(root2) )
			cout << "1\n";
		else {

			if( find(root1)  == find(root2+n) )
				cout << "2\n";
			else
				cout << "3\n";
		}
	}

	return 0;
}

/*
ll hate[maxn], love[maxn], sizeL[maxn], sizeH[maxn];

void inititialize(ll n){

	for(ll i=0; i<=n ;i++){
		sizeL[i]=1;
		sizeH[i]=1;
		love[i]=i;
		hate[i]=-1;
	}
	return ;
}

ll find_hate(ll root)
{
	while(root != hate[root])
	{
		root = hate[root];
	}

	return root;
}

ll find_love(ll root)
{
	while(root != love[root])
	{
		root = love[root];
	}
	return root;
}

ll union_love(ll rootA, ll rootB){
	ll root1 = find_love(rootA);
	ll root2 = find_love(rootB);

	if(root1==root2)
		return 1;

	ll croot1 = find_hate(root1);
	ll croot2 = find_hate(root2);

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeL[root1] > sizeL[root2]){
		love[root2] = love[root1];

		sizeL[root1] += sizeL[root2];

	} else {
		love[root1] = love[root2];

		sizeL[root2] += sizeL[root1];
	}

	hate[croot1] = hate[croot2];

	return 1;
}

ll union_hate(ll rootA, ll rootB)
{

	ll croot1 = find_love(rootA);
	ll croot2 = find_love(rootB);

	ll root1 = find_hate(croot1);
	ll root2 = find_hate(croot2);

	if(root1==root2)
		return 1;

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeH[croot1] > sizeH[croot2]){
		hate[croot2] = hate[croot1];

		sizeH[croot1] += sizeH[croot2];
	} else {
		hate[croot1] = hate[croot2];

		sizeH[croot2] += sizeH[croot1];
	}

	return 1;

}
*/


#include<bits/stdc++.h>

#define X first
#define Y second
#define eb push_back
#define pb pop_back
#define siz(a) int(a.size())
//for traversing the container (bcoz we cannot access linked list etc with direct index)
//c stands for container and it for iterator
#define tr(c, it) \
		for(typeof(c.begin()) it=c.begin() ; it != c.end() ; it++)

#define all(c) c.begin(), c.end()
#define present(container, element) (container.find(element) != container.end()) //whether the element is present in the container

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define scan(x) scanf("%lld", &x)
#define print(x) printf("%lld", x)
#define pN printf("\n");
using namespace std;

typedef long long int ll;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef vector < ll > vll;
typedef vector < vll > vvll;

typedef pair < int , int > ii;

const int mod=1e9+7;
const int maxn=1e5+5;

ll arr[2*maxn], n;

ll find(ll root){

	while(root != arr[root])
		root = arr[root];

	return root;
}

ll join(ll root1,ll root2, ll type){

	ll loveA = find(root1);
	ll loveB = find(root2);
	ll hateA = find(root1+n);
	ll hateB = find(root2+n);

	if(type == 1){
		if(loveA == hateB || loveB == hateA)
			return 0;

		arr[loveA] = arr[loveB];
		arr[hateA] = arr[hateB];

		return 1;
	} else{

		if(loveA == loveB || hateA == hateB)
			return 0;

		arr[loveA] = arr[hateB];
		arr[loveB] = arr[hateA];

		return 1;
	}

}

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

	ll m, q, ch, check, root1, root2, i;

	cin >> n >> m >> q;

	string str, str1, str2;

	//inititialize(n);

	map<string, ll > mp;

	for(i=1; i<=n; i++)
	{
		cin >> str;

		mp[str]=i;

		arr[i]=i;
		arr[i+n]=i+n;
	}
	map<string, ll> :: iterator it=mp.begin();
	while(m--){
		cin >> ch >> str1 >> str2;
		root1 = mp[str1];
		root2 = mp[str2];

		check=join(root1, root2, ch);

		//trace3(check, root1, root2);

		if(check==1)
			cout << "YES\n";
		else
			cout << "NO\n";

	//	for(i=1; i<=n; i++)
			//trace3(i, hate[i], love[i]);
	}

	while(q--) {
		cin >> str1 >> str2;

		root1 = mp[str1];
		root2 = mp[str2];

		//root1L = find_love(root1);
		//root2L = find_love(root2);

		if(	find(root1) == find(root2) )
			cout << "1\n";
		else {

			if( find(root1)  == find(root2+n) )
				cout << "2\n";
			else
				cout << "3\n";
		}
	}

	return 0;
}

/*
ll hate[maxn], love[maxn], sizeL[maxn], sizeH[maxn];

void inititialize(ll n){

	for(ll i=0; i<=n ;i++){
		sizeL[i]=1;
		sizeH[i]=1;
		love[i]=i;
		hate[i]=-1;
	}
	return ;
}

ll find_hate(ll root)
{
	while(root != hate[root])
	{
		root = hate[root];
	}

	return root;
}

ll find_love(ll root)
{
	while(root != love[root])
	{
		root = love[root];
	}
	return root;
}

ll union_love(ll rootA, ll rootB){
	ll root1 = find_love(rootA);
	ll root2 = find_love(rootB);

	if(root1==root2)
		return 1;

	ll croot1 = find_hate(root1);
	ll croot2 = find_hate(root2);

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeL[root1] > sizeL[root2]){
		love[root2] = love[root1];

		sizeL[root1] += sizeL[root2];

	} else {
		love[root1] = love[root2];

		sizeL[root2] += sizeL[root1];
	}

	hate[croot1] = hate[croot2];

	return 1;
}

ll union_hate(ll rootA, ll rootB)
{

	ll croot1 = find_love(rootA);
	ll croot2 = find_love(rootB);

	ll root1 = find_hate(croot1);
	ll root2 = find_hate(croot2);

	if(root1==root2)
		return 1;

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeH[croot1] > sizeH[croot2]){
		hate[croot2] = hate[croot1];

		sizeH[croot1] += sizeH[croot2];
	} else {
		hate[croot1] = hate[croot2];

		sizeH[croot2] += sizeH[croot1];
	}

	return 1;

}
*/


#include<bits/stdc++.h>

#define X first
#define Y second
#define eb push_back
#define pb pop_back
#define siz(a) int(a.size())
//for traversing the container (bcoz we cannot access linked list etc with direct index)
//c stands for container and it for iterator
#define tr(c, it) \
		for(typeof(c.begin()) it=c.begin() ; it != c.end() ; it++)

#define all(c) c.begin(), c.end()
#define present(container, element) (container.find(element) != container.end()) //whether the element is present in the container

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define scan(x) scanf("%lld", &x)
#define print(x) printf("%lld", x)
#define pN printf("\n");
using namespace std;

typedef long long int ll;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef vector < ll > vll;
typedef vector < vll > vvll;

typedef pair < int , int > ii;

const int mod=1e9+7;
const int maxn=2e5+50;

ll arr[maxn], n;

ll find(ll root){

	while(root != arr[root]){
		arr[root] = arr[arr[arr[root]]];
		root = arr[root];
	}
	return root;
}

ll join(ll root1,ll root2, ll type){

	ll loveA = find(root1);
	ll loveB = find(root2);
	ll hateA = find(root1+n);
	ll hateB = find(root2+n);

	if(type == 1){
		if(loveA == hateB)
			return 0;

		if(loveA != loveB)
			arr[loveA] = loveB;
		if(hateA != hateB)
			arr[hateA] = hateB;

		return 1;
	} else{

		if(loveA == loveB )
			return 0;

		if(loveA != hateB)
			arr[loveA] = hateB;

		if(hateA != loveB)
			arr[hateA] = loveB;

		return 1;
	}

}
map<string, int > mp;
int main()
{
	ios_base::sync_with_stdio(0);

	ll m, q, ch, check, root1, root2, i;

	cin >> n >> m >> q;

	string str, str1, str2;

	//inititialize(n);

	for(i=1; i<=n; i++)
	{
		cin >> str;

		mp[str]=i;

		arr[i]=i;
		arr[i+n]=i+n;
	}
	//map<string, ll> :: iterator it=mp.begin();
	while(m--){
		cin >> ch >> str1 >> str2;
		root1 = mp[str1];
		root2 = mp[str2];

		check=join(root1, root2, ch);

		//trace3(check, root1, root2);

		if(check==1)
			cout << "YES\n";
		else
			cout << "NO\n";

	//	for(i=1; i<=n; i++)
			//trace3(i, hate[i], love[i]);
	}

	while(q--) {
		cin >> str1 >> str2;

		root1 = mp[str1];
		root2 = mp[str2];

		//root1L = find_love(root1);
		//root2L = find_love(root2);

		if(	find(root1) == find(root2) )
			cout << "1\n";
		else {

			if( find(root1)  == find(root2+n) )
				cout << "2\n";
			else
				cout << "3\n";
		}
	}

	return 0;
}

/*
ll hate[maxn], love[maxn], sizeL[maxn], sizeH[maxn];

void inititialize(ll n){

	for(ll i=0; i<=n ;i++){
		sizeL[i]=1;
		sizeH[i]=1;
		love[i]=i;
		hate[i]=-1;
	}
	return ;
}

ll find_hate(ll root)
{
	while(root != hate[root])
	{
		root = hate[root];
	}

	return root;
}

ll find_love(ll root)
{
	while(root != love[root])
	{
		root = love[root];
	}
	return root;
}

ll union_love(ll rootA, ll rootB){
	ll root1 = find_love(rootA);
	ll root2 = find_love(rootB);

	if(root1==root2)
		return 1;

	ll croot1 = find_hate(root1);
	ll croot2 = find_hate(root2);

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeL[root1] > sizeL[root2]){
		love[root2] = love[root1];

		sizeL[root1] += sizeL[root2];

	} else {
		love[root1] = love[root2];

		sizeL[root2] += sizeL[root1];
	}

	hate[croot1] = hate[croot2];

	return 1;
}

ll union_hate(ll rootA, ll rootB)
{

	ll croot1 = find_love(rootA);
	ll croot2 = find_love(rootB);

	ll root1 = find_hate(croot1);
	ll root2 = find_hate(croot2);

	if(root1==root2)
		return 1;

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeH[croot1] > sizeH[croot2]){
		hate[croot2] = hate[croot1];

		sizeH[croot1] += sizeH[croot2];
	} else {
		hate[croot1] = hate[croot2];

		sizeH[croot2] += sizeH[croot1];
	}

	return 1;

}
*/


#include<bits/stdc++.h>

#define X first
#define Y second
#define eb push_back
#define pb pop_back
#define siz(a) int(a.size())
//for traversing the container (bcoz we cannot access linked list etc with direct index)
//c stands for container and it for iterator
#define tr(c, it) \
		for(typeof(c.begin()) it=c.begin() ; it != c.end() ; it++)

#define all(c) c.begin(), c.end()
#define present(container, element) (container.find(element) != container.end()) //whether the element is present in the container

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define scan(x) scanf("%lld", &x)
#define print(x) printf("%lld", x)
#define pN printf("\n");
using namespace std;

typedef long long int ll;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef vector < ll > vll;
typedef vector < vll > vvll;

typedef pair < int , int > ii;

const int mod=1e9+7;
const int maxn=2e5+50;

ll arr[maxn], n, size[maxn];

ll find(ll root){

	while(root != arr[root])
		root = arr[root];

	return root;
}

ll join(ll root1,ll root2, ll type){

	ll loveA = find(root1);
	ll loveB = find(root2);
	ll hateA = find(root1+n);
	ll hateB = find(root2+n);

	if(type == 1){
		if(loveA == hateB)
			return 0;

		if(size[loveA] > size[loveB]){
			arr[loveB] = loveA;
			size[loveA] += size[loveB];
		}
		else{
			arr[loveA] = loveB;
			size[loveB] += size[loveA];
		}
		if(size[hateA] > size[hateB]){
			arr[hateB] = arr[hateA];
			size[hateA] += size[hateB];
		}
		else{
			arr[hateA] = hateB;
			size[hateB] += size[hateA];
		}
		return 1;
	} else{

		if(loveA == loveB )
			return 0;

		if(size[loveA] > size[hateB]){
			arr[hateB] = loveA;
			size[loveA] += size[hateB];
		}
		else{
			arr[loveA] = hateB;
			size[hateB] += size[loveA];
		}
		if(size[hateA] > size[hateB]){

			arr[loveB] = hateA;
			size[hateA] += size[loveB];
		}
		else{
					arr[hateA] = loveB;
			size[hateB] += size[hateA];
		}
		return 1;
	}

}
map<string, int > mp;
int main()
{
	ios_base::sync_with_stdio(0);

	ll m, q, ch, check, root1, root2, i;

	cin >> n >> m >> q;

	string str, str1, str2;

	//inititialize(n);

	for(i=1; i<=n; i++)
	{
		cin >> str;

		mp[str]=i;

		size[i] = size[i+n] =1;

		arr[i]=i;
		arr[i+n]=i+n;
	}
	//map<string, ll> :: iterator it=mp.begin();
	while(m--){
		cin >> ch >> str1 >> str2;
		root1 = mp[str1];
		root2 = mp[str2];

		check=join(root1, root2, ch);

		//trace3(check, root1, root2);

		if(check==1)
			cout << "YES\n";
		else
			cout << "NO\n";

	//	for(i=1; i<=n; i++)
			//trace3(i, hate[i], love[i]);
	}

	while(q--) {
		cin >> str1 >> str2;

		root1 = mp[str1];
		root2 = mp[str2];

		//root1L = find_love(root1);
		//root2L = find_love(root2);

		if(	find(root1) == find(root2) )
			cout << "1\n";
		else {

			if( find(root1)  == find(root2+n) )
				cout << "2\n";
			else
				cout << "3\n";
		}
	}

	return 0;
}

/*
ll hate[maxn], love[maxn], sizeL[maxn], sizeH[maxn];

void inititialize(ll n){

	for(ll i=0; i<=n ;i++){
		sizeL[i]=1;
		sizeH[i]=1;
		love[i]=i;
		hate[i]=-1;
	}
	return ;
}

ll find_hate(ll root)
{
	while(root != hate[root])
	{
		root = hate[root];
	}

	return root;
}

ll find_love(ll root)
{
	while(root != love[root])
	{
		root = love[root];
	}
	return root;
}

ll union_love(ll rootA, ll rootB){
	ll root1 = find_love(rootA);
	ll root2 = find_love(rootB);

	if(root1==root2)
		return 1;

	ll croot1 = find_hate(root1);
	ll croot2 = find_hate(root2);

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeL[root1] > sizeL[root2]){
		love[root2] = love[root1];

		sizeL[root1] += sizeL[root2];

	} else {
		love[root1] = love[root2];

		sizeL[root2] += sizeL[root1];
	}

	hate[croot1] = hate[croot2];

	return 1;
}

ll union_hate(ll rootA, ll rootB)
{

	ll croot1 = find_love(rootA);
	ll croot2 = find_love(rootB);

	ll root1 = find_hate(croot1);
	ll root2 = find_hate(croot2);

	if(root1==root2)
		return 1;

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeH[croot1] > sizeH[croot2]){
		hate[croot2] = hate[croot1];

		sizeH[croot1] += sizeH[croot2];
	} else {
		hate[croot1] = hate[croot2];

		sizeH[croot2] += sizeH[croot1];
	}

	return 1;

}
*/


#include<bits/stdc++.h>

#define X first
#define Y second
#define eb push_back
#define pb pop_back
#define siz(a) int(a.size())
//for traversing the container (bcoz we cannot access linked list etc with direct index)
//c stands for container and it for iterator
#define tr(c, it) \
		for(typeof(c.begin()) it=c.begin() ; it != c.end() ; it++)

#define all(c) c.begin(), c.end()
#define present(container, element) (container.find(element) != container.end()) //whether the element is present in the container

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define scan(x) scanf("%lld", &x)
#define print(x) printf("%lld", x)
#define pN printf("\n");
using namespace std;

typedef long long int ll;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef vector < ll > vll;
typedef vector < vll > vvll;

typedef pair < int , int > ii;

const int mod=1e9+7;
const int maxn=1e5+5;

ll arr[2*maxn], n;

ll find(ll root){

	while(root != arr[root])
		root = arr[root];

	return root;
}

ll join(ll root1,ll root2, ll type){

	ll loveA = find(root1);
	ll loveB = find(root2);
	ll hateA = find(root1+n);
	ll hateB = find(root2+n);

	if(type == 1){
		if(loveA == hateB || loveB == hateA)
			return 0;

		arr[loveA] = arr[loveB];
		arr[hateA] = arr[hateB];

		return 1;
	} else{

		if(loveA == loveB || hateA == hateB)
			return 0;

		arr[loveA] = arr[hateB];
		arr[loveB] = arr[hateA];

		return 1;
	}

}

int main()
{
	ll m, q, ch, check, root1, root2, i;

	cin >> n >> m >> q;

	string str, str1, str2;

	//inititialize(n);

	map<string, ll > mp;

	for(i=1; i<=n; i++)
	{
		cin >> str;

		mp[str]=i;

		arr[i]=i;
		arr[i+n]=i+n;
	}
	map<string, ll> :: iterator it=mp.begin();
	while(m--){
		cin >> ch >> str1 >> str2;
		root1 = mp[str1];
		root2 = mp[str2];

		check=join(root1, root2, ch);

		//trace3(check, root1, root2);

		if(check==1)
			cout << "YES\n";
		else
			cout << "NO\n";

	//	for(i=1; i<=n; i++)
			//trace3(i, hate[i], love[i]);
	}

	while(q--) {
		cin >> str1 >> str2;

		root1 = mp[str1];
		root2 = mp[str2];

		//root1L = find_love(root1);
		//root2L = find_love(root2);

		if(	find(root1) == find(root2) )
			cout << "1\n";
		else {

			if( find(root1)  == find(root2+n) || find(root1 +n) == find(root2) )
				cout << "2\n";
			else
				cout << "3\n";
		}
	}

	return 0;
}

/*
ll hate[maxn], love[maxn], sizeL[maxn], sizeH[maxn];

void inititialize(ll n){

	for(ll i=0; i<=n ;i++){
		sizeL[i]=1;
		sizeH[i]=1;
		love[i]=i;
		hate[i]=-1;
	}
	return ;
}

ll find_hate(ll root)
{
	while(root != hate[root])
	{
		root = hate[root];
	}

	return root;
}

ll find_love(ll root)
{
	while(root != love[root])
	{
		root = love[root];
	}
	return root;
}

ll union_love(ll rootA, ll rootB){
	ll root1 = find_love(rootA);
	ll root2 = find_love(rootB);

	if(root1==root2)
		return 1;

	ll croot1 = find_hate(root1);
	ll croot2 = find_hate(root2);

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeL[root1] > sizeL[root2]){
		love[root2] = love[root1];

		sizeL[root1] += sizeL[root2];

	} else {
		love[root1] = love[root2];

		sizeL[root2] += sizeL[root1];
	}

	hate[croot1] = hate[croot2];

	return 1;
}

ll union_hate(ll rootA, ll rootB)
{

	ll croot1 = find_love(rootA);
	ll croot2 = find_love(rootB);

	ll root1 = find_hate(croot1);
	ll root2 = find_hate(croot2);

	if(root1==root2)
		return 1;

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeH[croot1] > sizeH[croot2]){
		hate[croot2] = hate[croot1];

		sizeH[croot1] += sizeH[croot2];
	} else {
		hate[croot1] = hate[croot2];

		sizeH[croot2] += sizeH[croot1];
	}

	return 1;

}
*/


#include<bits/stdc++.h>

#define X first
#define Y second
#define eb push_back
#define pb pop_back
#define siz(a) int(a.size())
//for traversing the container (bcoz we cannot access linked list etc with direct index)
//c stands for container and it for iterator
#define tr(c, it) \
		for(typeof(c.begin()) it=c.begin() ; it != c.end() ; it++)

#define all(c) c.begin(), c.end()
#define present(container, element) (container.find(element) != container.end()) //whether the element is present in the container

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define scan(x) scanf("%lld", &x)
#define print(x) printf("%lld", x)
#define pN printf("\n");
using namespace std;

typedef long long int ll;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef vector < ll > vll;
typedef vector < vll > vvll;

typedef pair < int , int > ii;

const int mod=1e9+7;
const int maxn=1e5+5;

ll arr[2*maxn], n;

ll find(ll root){

	while(root != arr[root])
		root = arr[root];

	return root;
}

ll join(ll root1,ll root2, ll type){

	ll loveA = find(root1);
	ll loveB = find(root2);
	ll hateA = find(root1+n);
	ll hateB = find(root2+n);

	if(type == 1){
		if(loveA == hateB || loveB == hateA)
			return 0;

		arr[loveA] = arr[loveB];
		arr[hateA] = arr[hateB];

		return 1;
	} else{

		if(loveA == loveB || hateA == hateB)
			return 0;

		arr[loveA] = arr[hateB];
		arr[loveB] = arr[hateA];

		return 1;
	}

}

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

	ll m, q, ch, check, root1, root2, i;

	cin >> n >> m >> q;

	string str, str1, str2;

	//inititialize(n);

	map<string, ll > mp;

	for(i=1; i<=n; i++)
	{
		cin >> str;

		mp[str]=i;

		arr[i]=i;
		arr[i+n]=i+n;
	}
	//map<string, ll> :: iterator it=mp.begin();
	while(m--){
		cin >> ch >> str1 >> str2;
		root1 = mp[str1];
		root2 = mp[str2];

		check=join(root1, root2, ch);

		//trace3(check, root1, root2);

		if(check==1)
			cout << "YES\n";
		else
			cout << "NO\n";

	//	for(i=1; i<=n; i++)
			//trace3(i, hate[i], love[i]);
	}

	while(q--) {
		cin >> str1 >> str2;

		root1 = mp[str1];
		root2 = mp[str2];

		//root1L = find_love(root1);
		//root2L = find_love(root2);

		if(	find(root1) == find(root2) )
			cout << "1\n";
		else {

			if( find(root1)  == find(root2+n) || find(root1 +n) == find(root2) )
				cout << "2\n";
			else
				cout << "3\n";
		}
	}

	return 0;
}

/*
ll hate[maxn], love[maxn], sizeL[maxn], sizeH[maxn];

void inititialize(ll n){

	for(ll i=0; i<=n ;i++){
		sizeL[i]=1;
		sizeH[i]=1;
		love[i]=i;
		hate[i]=-1;
	}
	return ;
}

ll find_hate(ll root)
{
	while(root != hate[root])
	{
		root = hate[root];
	}

	return root;
}

ll find_love(ll root)
{
	while(root != love[root])
	{
		root = love[root];
	}
	return root;
}

ll union_love(ll rootA, ll rootB){
	ll root1 = find_love(rootA);
	ll root2 = find_love(rootB);

	if(root1==root2)
		return 1;

	ll croot1 = find_hate(root1);
	ll croot2 = find_hate(root2);

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeL[root1] > sizeL[root2]){
		love[root2] = love[root1];

		sizeL[root1] += sizeL[root2];

	} else {
		love[root1] = love[root2];

		sizeL[root2] += sizeL[root1];
	}

	hate[croot1] = hate[croot2];

	return 1;
}

ll union_hate(ll rootA, ll rootB)
{

	ll croot1 = find_love(rootA);
	ll croot2 = find_love(rootB);

	ll root1 = find_hate(croot1);
	ll root2 = find_hate(croot2);

	if(root1==root2)
		return 1;

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeH[croot1] > sizeH[croot2]){
		hate[croot2] = hate[croot1];

		sizeH[croot1] += sizeH[croot2];
	} else {
		hate[croot1] = hate[croot2];

		sizeH[croot2] += sizeH[croot1];
	}

	return 1;

}
*/


#include<bits/stdc++.h>

#define X first
#define Y second
#define eb push_back
#define pb pop_back
#define siz(a) int(a.size())
//for traversing the container (bcoz we cannot access linked list etc with direct index)
//c stands for container and it for iterator
#define tr(c, it) \
		for(typeof(c.begin()) it=c.begin() ; it != c.end() ; it++)

#define all(c) c.begin(), c.end()
#define present(container, element) (container.find(element) != container.end()) //whether the element is present in the container

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define scan(x) scanf("%lld", &x)
#define print(x) printf("%lld", x)
#define pN printf("\n");
using namespace std;

typedef long long int ll;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef vector < ll > vll;
typedef vector < vll > vvll;

typedef pair < int , int > ii;

const int mod=1e9+7;
const int maxn=1e5+5;

ll arr[2*maxn], n;

ll find(ll root){

	while(root != arr[root])
		root = arr[root];

	return root;
}

ll join(ll root1,ll root2, ll type){

	ll loveA = find(root1);
	ll loveB = find(root2);
	ll hateA = find(root1+n);
	ll hateB = find(root2+n);

	if(type == 1){
		if(loveA == hateB || loveB == hateA)
			return 0;

		arr[loveA] = loveB;
		arr[hateA] = hateB;

		return 1;
	} else{

		if(loveA == loveB || hateA == hateB)
			return 0;

		arr[loveA] = hateB;
		arr[hateA] = loveB;

		return 1;
	}

}
map<string, int > mp;
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0);

	ll m, q, ch, check, root1, root2, i;

	cin >> n >> m >> q;

	string str, str1, str2;

	//inititialize(n);

	for(i=1; i<=n; i++)
	{
		cin >> str;

		mp[str]=i;

		arr[i]=i;
		arr[i+n]=i+n;
	}
	//map<string, ll> :: iterator it=mp.begin();
	while(m--){
		cin >> ch >> str1 >> str2;
		root1 = mp[str1];
		root2 = mp[str2];

		check=join(root1, root2, ch);

		//trace3(check, root1, root2);

		if(check==1)
			cout << "YES\n";
		else
			cout << "NO\n";

	//	for(i=1; i<=n; i++)
			//trace3(i, hate[i], love[i]);
	}

	while(q--) {
		cin >> str1 >> str2;

		root1 = mp[str1];
		root2 = mp[str2];

		//root1L = find_love(root1);
		//root2L = find_love(root2);

		if(	find(root1) == find(root2) )
			cout << "1\n";
		else {

			if( find(root1)  == find(root2+n) )
				cout << "2\n";
			else
				cout << "3\n";
		}
	}

	return 0;
}

/*
ll hate[maxn], love[maxn], sizeL[maxn], sizeH[maxn];

void inititialize(ll n){

	for(ll i=0; i<=n ;i++){
		sizeL[i]=1;
		sizeH[i]=1;
		love[i]=i;
		hate[i]=-1;
	}
	return ;
}

ll find_hate(ll root)
{
	while(root != hate[root])
	{
		root = hate[root];
	}

	return root;
}

ll find_love(ll root)
{
	while(root != love[root])
	{
		root = love[root];
	}
	return root;
}

ll union_love(ll rootA, ll rootB){
	ll root1 = find_love(rootA);
	ll root2 = find_love(rootB);

	if(root1==root2)
		return 1;

	ll croot1 = find_hate(root1);
	ll croot2 = find_hate(root2);

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeL[root1] > sizeL[root2]){
		love[root2] = love[root1];

		sizeL[root1] += sizeL[root2];

	} else {
		love[root1] = love[root2];

		sizeL[root2] += sizeL[root1];
	}

	hate[croot1] = hate[croot2];

	return 1;
}

ll union_hate(ll rootA, ll rootB)
{

	ll croot1 = find_love(rootA);
	ll croot2 = find_love(rootB);

	ll root1 = find_hate(croot1);
	ll root2 = find_hate(croot2);

	if(root1==root2)
		return 1;

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeH[croot1] > sizeH[croot2]){
		hate[croot2] = hate[croot1];

		sizeH[croot1] += sizeH[croot2];
	} else {
		hate[croot1] = hate[croot2];

		sizeH[croot2] += sizeH[croot1];
	}

	return 1;

}
*/


#include<bits/stdc++.h>

#define X first
#define Y second
#define eb push_back
#define pb pop_back
#define siz(a) int(a.size())
//for traversing the container (bcoz we cannot access linked list etc with direct index)
//c stands for container and it for iterator
#define tr(c, it) \
		for(typeof(c.begin()) it=c.begin() ; it != c.end() ; it++)

#define all(c) c.begin(), c.end()
#define present(container, element) (container.find(element) != container.end()) //whether the element is present in the container

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define scan(x) scanf("%lld", &x)
#define print(x) printf("%lld", x)
#define pN printf("\n");
using namespace std;

typedef long long int ll;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef vector < ll > vll;
typedef vector < vll > vvll;

typedef pair < int , int > ii;

const int mod=1e9+7;
const int maxn=2e5+5;

ll arr[maxn], n;

ll find(ll root){

	while(root != arr[root])
		root = arr[root];

	return root;
}

ll join(ll root1,ll root2, ll type){

	ll loveA = find(root1);
	ll loveB = find(root2);
	ll hateA = find(root1+n);
	ll hateB = find(root2+n);

	if(type == 1){
		if(loveA == hateB || loveB == hateA)
			return 0;

		arr[loveA] = arr[loveB];
		arr[hateA] = arr[hateB];

		return 1;
	} else{

		if(loveA == loveB || hateA == hateB)
			return 0;

		arr[loveA] = arr[hateB];
		arr[loveB] = arr[hateA];

		return 1;
	}

}
map<string, int > mp;
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0);

	ll m, q, ch, check, root1, root2, i;

	cin >> n >> m >> q;

	string str, str1, str2;

	//inititialize(n);

	for(i=1; i<=n; i++)
	{
		cin >> str;

		mp[str]=i;

		arr[i]=i;
		arr[i+n]=i+n;
	}
	//map<string, ll> :: iterator it=mp.begin();
	while(m--){
		cin >> ch >> str1 >> str2;
		root1 = mp[str1];
		root2 = mp[str2];

		check=join(root1, root2, ch);

		//trace3(check, root1, root2);

		if(check==1)
			cout << "YES\n";
		else
			cout << "NO\n";

	//	for(i=1; i<=n; i++)
			//trace3(i, hate[i], love[i]);
	}

	while(q--) {
		cin >> str1 >> str2;

		root1 = mp[str1];
		root2 = mp[str2];

		//root1L = find_love(root1);
		//root2L = find_love(root2);

		if(	find(root1) == find(root2) )
			cout << "1\n";
		else {

			if( find(root1)  == find(root2+n) )
				cout << "2\n";
			else
				cout << "3\n";
		}
	}

	return 0;
}


#include<bits/stdc++.h>

#define X first
#define Y second
#define eb push_back
#define pb pop_back
#define siz(a) int(a.size())
//for traversing the container (bcoz we cannot access linked list etc with direct index)
//c stands for container and it for iterator
#define tr(c, it) \
		for(typeof(c.begin()) it=c.begin() ; it != c.end() ; it++)

#define all(c) c.begin(), c.end()
#define present(container, element) (container.find(element) != container.end()) //whether the element is present in the container

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define scan(x) scanf("%lld", &x)
#define print(x) printf("%lld", x)
#define pN printf("\n");
using namespace std;

typedef long long int ll;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef vector < ll > vll;
typedef vector < vll > vvll;

typedef pair < int , int > ii;

const int mod=1e9+7;
const int maxn=2e5+50;

ll arr[maxn], n, size[maxn];

ll find(ll root){

	while(root != arr[root])
		root = arr[root];

	return root;
}

ll join(ll root1,ll root2, ll type){

	ll loveA = find(root1);
	ll loveB = find(root2);
	ll hateA = find(root1+n);
	ll hateB = find(root2+n);

	if(type == 1){
		if(loveA == hateB)
			return 0;

		if(size[loveA] > size[loveB]){
			arr[loveB] = loveA;
			size[loveA] += size[loveB];
		}
		else{
			arr[loveA] = loveB;
			size[loveB] += size[loveA];
		}
		if(size[hateA] > size[hateB]){
			arr[hateB] = hateA;
			size[hateA] += size[hateB];
		}
		else{
			arr[hateA] = hateB;
			size[hateB] += size[hateA];
		}
		return 1;
	} else{

		if(loveA == loveB )
			return 0;

		if(size[loveA] > size[hateB]){
			arr[hateB] = loveA;
			size[loveA] += size[hateB];
		}
		else{
			arr[loveA] = hateB;
			size[hateB] += size[loveA];
		}
		if(size[hateA] > size[hateB]){

			arr[loveB] = hateA;
			size[hateA] += size[loveB];
		}
		else{
			arr[hateA] = loveB;
			size[hateB] += size[hateA];
		}
		return 1;
	}

}
map<string, int > mp;
int main()
{
	ios_base::sync_with_stdio(0);

	ll m, q, ch, check, root1, root2, i;

	cin >> n >> m >> q;

	string str, str1, str2;

	//inititialize(n);

	for(i=1; i<=n; i++)
	{
		cin >> str;

		mp[str]=i;

		size[i] = size[i+n] =1;

		arr[i]=i;
		arr[i+n]=i+n;
	}
	//map<string, ll> :: iterator it=mp.begin();
	while(m--){
		cin >> ch >> str1 >> str2;
		root1 = mp[str1];
		root2 = mp[str2];

		check=join(root1, root2, ch);

		//trace3(check, root1, root2);

		if(check==1)
			cout << "YES\n";
		else
			cout << "NO\n";

	//	for(i=1; i<=n; i++)
			//trace3(i, hate[i], love[i]);
	}

	while(q--) {
		cin >> str1 >> str2;

		root1 = mp[str1];
		root2 = mp[str2];

		//root1L = find_love(root1);
		//root2L = find_love(root2);

		if(	find(root1) == find(root2) )
			cout << "1\n";
		else {

			if( find(root1)  == find(root2+n) )
				cout << "2\n";
			else
				cout << "3\n";
		}
	}

	return 0;
}

/*
ll hate[maxn], love[maxn], sizeL[maxn], sizeH[maxn];

void inititialize(ll n){

	for(ll i=0; i<=n ;i++){
		sizeL[i]=1;
		sizeH[i]=1;
		love[i]=i;
		hate[i]=-1;
	}
	return ;
}

ll find_hate(ll root)
{
	while(root != hate[root])
	{
		root = hate[root];
	}

	return root;
}

ll find_love(ll root)
{
	while(root != love[root])
	{
		root = love[root];
	}
	return root;
}

ll union_love(ll rootA, ll rootB){
	ll root1 = find_love(rootA);
	ll root2 = find_love(rootB);

	if(root1==root2)
		return 1;

	ll croot1 = find_hate(root1);
	ll croot2 = find_hate(root2);

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeL[root1] > sizeL[root2]){
		love[root2] = love[root1];

		sizeL[root1] += sizeL[root2];

	} else {
		love[root1] = love[root2];

		sizeL[root2] += sizeL[root1];
	}

	hate[croot1] = hate[croot2];

	return 1;
}

ll union_hate(ll rootA, ll rootB)
{

	ll croot1 = find_love(rootA);
	ll croot2 = find_love(rootB);

	ll root1 = find_hate(croot1);
	ll root2 = find_hate(croot2);

	if(root1==root2)
		return 1;

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeH[croot1] > sizeH[croot2]){
		hate[croot2] = hate[croot1];

		sizeH[croot1] += sizeH[croot2];
	} else {
		hate[croot1] = hate[croot2];

		sizeH[croot2] += sizeH[croot1];
	}

	return 1;

}
*/


#include<bits/stdc++.h>

#define X first
#define Y second
#define eb push_back
#define pb pop_back
#define siz(a) int(a.size())
//for traversing the container (bcoz we cannot access linked list etc with direct index)
//c stands for container and it for iterator
#define tr(c, it) \
		for(typeof(c.begin()) it=c.begin() ; it != c.end() ; it++)

#define all(c) c.begin(), c.end()
#define present(container, element) (container.find(element) != container.end()) //whether the element is present in the container

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define scan(x) scanf("%lld", &x)
#define print(x) printf("%lld", x)
#define pN printf("\n");
using namespace std;

typedef long long int ll;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef vector < ll > vll;
typedef vector < vll > vvll;

typedef pair < int , int > ii;

const int mod=1e9+7;
const int maxn=2e5+50;

ll arr[maxn], n, size[maxn];

ll find(ll root){

	while(root != arr[root])
		root = arr[root];

	return root;
}

ll join(ll root1,ll root2, ll type){

	ll loveA = find(root1);
	ll loveB = find(root2);
	ll hateA = find(root1+n);
	ll hateB = find(root2+n);

	if(type == 1){
		if(loveA == hateB)
			return 0;

		if(size[loveA] > size[loveB]){
			arr[loveA] = loveB;
			size[loveA] += size[loveB];
		}
		else{
			arr[loveB] = loveA;
			size[loveB] += size[loveA];
		}
		if(size[hateA] > size[hateB]){
			arr[hateA] = hateB;
			size[hateA] += size[hateB];
		}
		else{
			arr[hateB] = arr[hateA];
			size[hateB] += size[hateA];
		}
		return 1;
	} else{

		if(loveA == loveB )
			return 0;

		if(size[loveA] > size[hateB]){
			arr[loveA] = hateB;
			size[loveA] += size[hateB];
		}
		else{
			arr[hateB] = loveA;
			size[hateB] += size[loveA];
		}
		if(size[hateA] > size[hateB]){
			arr[hateA] = loveB;
			size[hateA] += size[loveB];
		}
		else{
			arr[loveB] = hateA;
			size[hateB] += size[hateA];
		}
		return 1;
	}

}
map<string, int > mp;
int main()
{
	ios_base::sync_with_stdio(0);

	ll m, q, ch, check, root1, root2, i;

	cin >> n >> m >> q;

	string str, str1, str2;

	//inititialize(n);

	for(i=1; i<=n; i++)
	{
		cin >> str;

		mp[str]=i;

		size[i] = size[i+n] =1;

		arr[i]=i;
		arr[i+n]=i+n;
	}
	//map<string, ll> :: iterator it=mp.begin();
	while(m--){
		cin >> ch >> str1 >> str2;
		root1 = mp[str1];
		root2 = mp[str2];

		check=join(root1, root2, ch);

		//trace3(check, root1, root2);

		if(check==1)
			cout << "YES\n";
		else
			cout << "NO\n";

	//	for(i=1; i<=n; i++)
			//trace3(i, hate[i], love[i]);
	}

	while(q--) {
		cin >> str1 >> str2;

		root1 = mp[str1];
		root2 = mp[str2];

		//root1L = find_love(root1);
		//root2L = find_love(root2);

		if(	find(root1) == find(root2) )
			cout << "1\n";
		else {

			if( find(root1)  == find(root2+n) )
				cout << "2\n";
			else
				cout << "3\n";
		}
	}

	return 0;
}

/*
ll hate[maxn], love[maxn], sizeL[maxn], sizeH[maxn];

void inititialize(ll n){

	for(ll i=0; i<=n ;i++){
		sizeL[i]=1;
		sizeH[i]=1;
		love[i]=i;
		hate[i]=-1;
	}
	return ;
}

ll find_hate(ll root)
{
	while(root != hate[root])
	{
		root = hate[root];
	}

	return root;
}

ll find_love(ll root)
{
	while(root != love[root])
	{
		root = love[root];
	}
	return root;
}

ll union_love(ll rootA, ll rootB){
	ll root1 = find_love(rootA);
	ll root2 = find_love(rootB);

	if(root1==root2)
		return 1;

	ll croot1 = find_hate(root1);
	ll croot2 = find_hate(root2);

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeL[root1] > sizeL[root2]){
		love[root2] = love[root1];

		sizeL[root1] += sizeL[root2];

	} else {
		love[root1] = love[root2];

		sizeL[root2] += sizeL[root1];
	}

	hate[croot1] = hate[croot2];

	return 1;
}

ll union_hate(ll rootA, ll rootB)
{

	ll croot1 = find_love(rootA);
	ll croot2 = find_love(rootB);

	ll root1 = find_hate(croot1);
	ll root2 = find_hate(croot2);

	if(root1==root2)
		return 1;

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeH[croot1] > sizeH[croot2]){
		hate[croot2] = hate[croot1];

		sizeH[croot1] += sizeH[croot2];
	} else {
		hate[croot1] = hate[croot2];

		sizeH[croot2] += sizeH[croot1];
	}

	return 1;

}
*/


#include<bits/stdc++.h>

#define X first
#define Y second
#define eb push_back
#define pb pop_back
#define siz(a) int(a.size())
//for traversing the container (bcoz we cannot access linked list etc with direct index)
//c stands for container and it for iterator
#define tr(c, it) \
		for(typeof(c.begin()) it=c.begin() ; it != c.end() ; it++)

#define all(c) c.begin(), c.end()
#define present(container, element) (container.find(element) != container.end()) //whether the element is present in the container

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define scan(x) scanf("%lld", &x)
#define print(x) printf("%lld", x)
#define pN printf("\n");
using namespace std;

typedef long long int ll;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef vector < ll > vll;
typedef vector < vll > vvll;

typedef pair < int , int > ii;

const int mod=1e9+7;
const int maxn=2e5+50;

ll arr[maxn], n, size[maxn];

ll find(ll root){

	while(root != arr[root])
		root = arr[root];

	return root;
}

ll join(ll root1,ll root2, ll type){

	ll loveA = find(root1);
	ll loveB = find(root2);
	ll hateA = find(root1+n);
	ll hateB = find(root2+n);

	if(type == 1){
		if(loveA == hateB)
			return 0;

		if(size[loveA] > size[loveB]){
			arr[loveA] = loveB;
			size[loveA] = size[loveB];
		}
		else{
			arr[loveB] = loveA;
			size[loveB] = size[loveA];
		}
		if(size[hateA] > size[hateB]){
			arr[hateA] = hateB;
			size[hateA] = size[hateB];
		}
		else{
			arr[hateB] = arr[hateA];
			size[hateB] = size[hateA];
		}
		return 1;
	} else{

		if(loveA == loveB )
			return 0;

		if(size[loveA] > size[hateB]){
			arr[loveA] = hateB;
			size[loveA] = size[hateB];
		}
		else{
			arr[hateB] = loveA;
			size[hateB] = size[loveA];
		}
		if(size[hateA] > size[hateB]){
			arr[hateA] = loveB;
			size[hateA] = size[loveB];
		}
		else{
			arr[loveB] = hateA;
			size[hateB] = size[hateA];
		}
		return 1;
	}

}
map<string, int > mp;
int main()
{
	ios_base::sync_with_stdio(0);

	ll m, q, ch, check, root1, root2, i;

	cin >> n >> m >> q;

	string str, str1, str2;

	//inititialize(n);

	for(i=1; i<=n; i++)
	{
		cin >> str;

		mp[str]=i;

		size[i] = size[i+n] =1;

		arr[i]=i;
		arr[i+n]=i+n;
	}
	//map<string, ll> :: iterator it=mp.begin();
	while(m--){
		cin >> ch >> str1 >> str2;
		root1 = mp[str1];
		root2 = mp[str2];

		check=join(root1, root2, ch);

		//trace3(check, root1, root2);

		if(check==1)
			cout << "YES\n";
		else
			cout << "NO\n";

	//	for(i=1; i<=n; i++)
			//trace3(i, hate[i], love[i]);
	}

	while(q--) {
		cin >> str1 >> str2;

		root1 = mp[str1];
		root2 = mp[str2];

		//root1L = find_love(root1);
		//root2L = find_love(root2);

		if(	find(root1) == find(root2) )
			cout << "1\n";
		else {

			if( find(root1)  == find(root2+n) )
				cout << "2\n";
			else
				cout << "3\n";
		}
	}

	return 0;
}

/*
ll hate[maxn], love[maxn], sizeL[maxn], sizeH[maxn];

void inititialize(ll n){

	for(ll i=0; i<=n ;i++){
		sizeL[i]=1;
		sizeH[i]=1;
		love[i]=i;
		hate[i]=-1;
	}
	return ;
}

ll find_hate(ll root)
{
	while(root != hate[root])
	{
		root = hate[root];
	}

	return root;
}

ll find_love(ll root)
{
	while(root != love[root])
	{
		root = love[root];
	}
	return root;
}

ll union_love(ll rootA, ll rootB){
	ll root1 = find_love(rootA);
	ll root2 = find_love(rootB);

	if(root1==root2)
		return 1;

	ll croot1 = find_hate(root1);
	ll croot2 = find_hate(root2);

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeL[root1] > sizeL[root2]){
		love[root2] = love[root1];

		sizeL[root1] += sizeL[root2];

	} else {
		love[root1] = love[root2];

		sizeL[root2] += sizeL[root1];
	}

	hate[croot1] = hate[croot2];

	return 1;
}

ll union_hate(ll rootA, ll rootB)
{

	ll croot1 = find_love(rootA);
	ll croot2 = find_love(rootB);

	ll root1 = find_hate(croot1);
	ll root2 = find_hate(croot2);

	if(root1==root2)
		return 1;

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeH[croot1] > sizeH[croot2]){
		hate[croot2] = hate[croot1];

		sizeH[croot1] += sizeH[croot2];
	} else {
		hate[croot1] = hate[croot2];

		sizeH[croot2] += sizeH[croot1];
	}

	return 1;

}
*/


#include<bits/stdc++.h>

#define X first
#define Y second
#define eb push_back
#define pb pop_back
#define siz(a) int(a.size())
//for traversing the container (bcoz we cannot access linked list etc with direct index)
//c stands for container and it for iterator
#define tr(c, it) \
		for(typeof(c.begin()) it=c.begin() ; it != c.end() ; it++)

#define all(c) c.begin(), c.end()
#define present(container, element) (container.find(element) != container.end()) //whether the element is present in the container

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define scan(x) scanf("%lld", &x)
#define print(x) printf("%lld", x)
#define pN printf("\n");
using namespace std;

typedef long long int ll;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef vector < ll > vll;
typedef vector < vll > vvll;

typedef pair < int , int > ii;

const int mod=1e9+7;
const int maxn=2e5+5;

ll arr[maxn], n;

ll find(ll root){

	while(root != arr[root])
		root = arr[root];

	return root;
}

ll join(ll root1,ll root2, ll type){

	ll loveA = find(root1);
	ll loveB = find(root2);
	ll hateA = find(root1+n);
	ll hateB = find(root2+n);

	if(type == 1){
		if(loveA == hateB)
			return 0;

		arr[loveA] = loveB;
		arr[hateA] = hateB;

		return 1;
	} else{

		if(loveA == loveB )
			return 0;

		arr[loveA] = hateB;
		arr[hateA] = loveB;

		return 1;
	}

}
map<string, int > mp;
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0);

	ll m, q, root1, root2, i;

	cin >> n >> m >> q;

	string str, str1, str2;

	//inititialize(n);

	for(i=1; i<=n; i++)
	{
		cin >> str;

		mp[str]=i;

		arr[i]=i;
		arr[i+n]=i+n;
	}
	int type;
	//map<string, ll> :: iterator it=mp.begin();
	while(m--){
		cin >> type >> str1 >> str2;
		root1 = mp[str1];
		root2 = mp[str2];

		//check=join(root1, root2, ch);
		ll loveA = find(root1);
		ll loveB = find(root2);
		ll hateA = find(root1+n);
		ll hateB = find(root2+n);

		if(type == 1){
			if(loveA == hateB)
				cout << "NO\n";//return 0;

			arr[loveA] = loveB;
			arr[hateA] = hateB;
			cout << "YES\n";
			//return 1;
		} else{

			if(loveA == loveB )
				cout << "NO\n";//return 0;

			arr[loveA] = hateB;
			arr[hateA] = loveB;
			cout << "YES\n";
			//return 1;
		}
		//trace3(check, root1, root2);

	//	for(i=1; i<=n; i++)
			//trace3(i, hate[i], love[i]);
	}

	while(q--) {
		cin >> str1 >> str2;

		root1 = mp[str1];
		root2 = mp[str2];

		//root1L = find_love(root1);
		//root2L = find_love(root2);

		if(	find(root1) == find(root2) )
			cout << "1\n";
		else {

			if( find(root1)  == find(root2+n) )
				cout << "2\n";
			else
				cout << "3\n";
		}
	}

	return 0;
}

/*
ll hate[maxn], love[maxn], sizeL[maxn], sizeH[maxn];

void inititialize(ll n){

	for(ll i=0; i<=n ;i++){
		sizeL[i]=1;
		sizeH[i]=1;
		love[i]=i;
		hate[i]=-1;
	}
	return ;
}

ll find_hate(ll root)
{
	while(root != hate[root])
	{
		root = hate[root];
	}

	return root;
}

ll find_love(ll root)
{
	while(root != love[root])
	{
		root = love[root];
	}
	return root;
}

ll union_love(ll rootA, ll rootB){
	ll root1 = find_love(rootA);
	ll root2 = find_love(rootB);

	if(root1==root2)
		return 1;

	ll croot1 = find_hate(root1);
	ll croot2 = find_hate(root2);

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeL[root1] > sizeL[root2]){
		love[root2] = love[root1];

		sizeL[root1] += sizeL[root2];

	} else {
		love[root1] = love[root2];

		sizeL[root2] += sizeL[root1];
	}

	hate[croot1] = hate[croot2];

	return 1;
}

ll union_hate(ll rootA, ll rootB)
{

	ll croot1 = find_love(rootA);
	ll croot2 = find_love(rootB);

	ll root1 = find_hate(croot1);
	ll root2 = find_hate(croot2);

	if(root1==root2)
		return 1;

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeH[croot1] > sizeH[croot2]){
		hate[croot2] = hate[croot1];

		sizeH[croot1] += sizeH[croot2];
	} else {
		hate[croot1] = hate[croot2];

		sizeH[croot2] += sizeH[croot1];
	}

	return 1;

}
*/


#include<bits/stdc++.h>

#define X first
#define Y second
#define eb push_back
#define pb pop_back
#define siz(a) int(a.size())
//for traversing the container (bcoz we cannot access linked list etc with direct index)
//c stands for container and it for iterator
#define tr(c, it) \
		for(typeof(c.begin()) it=c.begin() ; it != c.end() ; it++)

#define all(c) c.begin(), c.end()
#define present(container, element) (container.find(element) != container.end()) //whether the element is present in the container

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define scan(x) scanf("%lld", &x)
#define print(x) printf("%lld", x)
#define pN printf("\n");
using namespace std;

typedef long long int ll;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef vector < ll > vll;
typedef vector < vll > vvll;

typedef pair < int , int > ii;

const int mod=1e9+7;
const int maxn=2e5+5;

ll arr[maxn], n;

ll find(ll root){

	while(root != arr[root])
		root = arr[root];

	return root;
}

ll join(ll root1,ll root2, ll type){

	ll loveA = find(root1);
	ll loveB = find(root2);
	ll hateA = find(root1+n);
	ll hateB = find(root2+n);

	if(type == 1){
		if(loveA == hateB)
			return 0;

		arr[loveA] = loveB;
		arr[hateA] = hateB;

		return 1;
	} else{

		if(loveA == loveB )
			return 0;

		arr[loveA] = hateB;
		arr[hateA] = loveB;

		return 1;
	}

}
map<string, int > mp;
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0);

	ll m, q, root1, root2, i;

	cin >> n >> m >> q;

	string str, str1, str2;

	//inititialize(n);

	for(i=1; i<=n; i++)
	{
		cin >> str;

		mp[str]=i;

		arr[i]=i;
		arr[i+n]=i+n;
	}
	int type;
	//map<string, ll> :: iterator it=mp.begin();
	while(m--){
		cin >> type >> str1 >> str2;
		root1 = mp[str1];
		root2 = mp[str2];

		//check=join(root1, root2, ch);
		ll loveA = find(root1);
		ll loveB = find(root2);
		ll hateA = find(root1+n);
		ll hateB = find(root2+n);

		if(type == 1){
			if(loveA == hateB){
				cout << "NO\n";//return 0;
			} else{
				arr[loveA] = loveB;
				arr[hateA] = hateB;
				cout << "YES\n";
			}
			//return 1;
		} else{

			if(loveA == loveB ){
				cout << "NO\n";//return 0;
			}else{
				arr[loveA] = hateB;
				arr[hateA] = loveB;
				cout << "YES\n";
			}//return 1;
		}
		//trace3(check, root1, root2);

	//	for(i=1; i<=n; i++)
			//trace3(i, hate[i], love[i]);
	}

	while(q--) {
		cin >> str1 >> str2;

		root1 = mp[str1];
		root2 = mp[str2];

		//root1L = find_love(root1);
		//root2L = find_love(root2);

		if(	find(root1) == find(root2) )
			cout << "1\n";
		else {

			if( find(root1)  == find(root2+n) )
				cout << "2\n";
			else
				cout << "3\n";
		}
	}

	return 0;
}

/*
ll hate[maxn], love[maxn], sizeL[maxn], sizeH[maxn];

void inititialize(ll n){

	for(ll i=0; i<=n ;i++){
		sizeL[i]=1;
		sizeH[i]=1;
		love[i]=i;
		hate[i]=-1;
	}
	return ;
}

ll find_hate(ll root)
{
	while(root != hate[root])
	{
		root = hate[root];
	}

	return root;
}

ll find_love(ll root)
{
	while(root != love[root])
	{
		root = love[root];
	}
	return root;
}

ll union_love(ll rootA, ll rootB){
	ll root1 = find_love(rootA);
	ll root2 = find_love(rootB);

	if(root1==root2)
		return 1;

	ll croot1 = find_hate(root1);
	ll croot2 = find_hate(root2);

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeL[root1] > sizeL[root2]){
		love[root2] = love[root1];

		sizeL[root1] += sizeL[root2];

	} else {
		love[root1] = love[root2];

		sizeL[root2] += sizeL[root1];
	}

	hate[croot1] = hate[croot2];

	return 1;
}

ll union_hate(ll rootA, ll rootB)
{

	ll croot1 = find_love(rootA);
	ll croot2 = find_love(rootB);

	ll root1 = find_hate(croot1);
	ll root2 = find_hate(croot2);

	if(root1==root2)
		return 1;

	trace3(rootA, root1, croot1);
	trace3(rootB, root2, croot2);
	if(croot1 == croot2)
		return -1;

	if(sizeH[croot1] > sizeH[croot2]){
		hate[croot2] = hate[croot1];

		sizeH[croot1] += sizeH[croot2];
	} else {
		hate[croot1] = hate[croot2];

		sizeH[croot2] += sizeH[croot1];
	}

	return 1;

}
*/


x=int(input())
a=list(map(int,input().split()))
c=sum(a)
d=max(a)
if d<=c and x>1 and c%2==0:
    print("YES")
else:
    print("NO")


x=int(input())
a=list(map(int,input().split()))
c=sum(a)
d=max(a)
if d<=c//2 and x>1 and c%2==0:
    print("YES")
else:
    print("NO")


input()
a = [int(s) for s in input().split()]
m = max(a)
s = sum(a)-m
if s >= m and s % 2 == m % 2:
    print('YES')
else:
    print('NO')


n = int(input())
a = [int(s) for s in input().split()]
if n > 2:
    a.sort(reverse = True)
    while a[1] > 0 and a[2] > 0:
        d = a[1]-a[2]+1
        a[0] -= d
        a[1] -= d
        k = 2
        for j in range(3,n):
            if a[j] == a[2]:
                k = j
            else:
                break
        olda1 = a[1]
        a[1] = a[2]
        a[k] = olda1
        if a[0] < a[1]:
            olda0 = a[0]
            a[0] = a[1]
            a[k-1] = olda0
print('YES' if a[0] == a[1] else 'NO')


n = int(input())
a = [int(s) for s in input().split()]
m = max(a)
s = sum(a) - max(a)
if s >= m and s % 2 == m % 2:
    print('YES')
else:
    print('NO')


n = int(input())
a = [int(s) for s in input().split()]
odd = 0
for i in a:
    if i % 2 == 1:
        odd += 1
print('YES' if odd % 2 == 0 else 'NO')


n = int(input())
a = [int(s) for s in input().split()]
if n > 2:
    a.sort(reverse = True)
    while a[1] > 0 and a[2] > 0:
        d = a[1]-a[2]+1
        a[0] -= d
        a[1] -= d
        a.sort(reverse = True)
print('YES' if a[0] == a[1] else 'NO')


n = int(input())
a = [int(s) for s in input().split()]
m = max(a)
s = sum(a)-m
if s >= m and s % 2 == m % 2:
    print('YES')
else:
    print('NO')


n = int(input())
a = [int(s) for s in input().split()]
if n > 2:
    a.sort(reverse = True)
    while a[1] > 0 and a[2] > 0:
        d = a[1]
        a[0] -= d
        a[1] -= d
        a.sort(reverse = True)
print('YES' if a[0] == a[1] else 'NO')


def answer(n,A):
    s=sum(A)
    if s%2==0:
        return "YES"
    else:
        return "NO"

n=int(input())
arr=list(map(int,input().split()))
print(answer(n,arr))


def answer(n,A):
    s=sum(A)
    if s%2==0:
        if max(A)<=s-max(A):
            return "YES"
        else:
            return "NO"
    else:
        return "NO"

n=int(input())
arr=list(map(int,input().split()))
print(answer(n,arr))


n=int(input())
inp = input()
a=[int(ele) for ele in inp.split()]
a.sort()
count=0
for ele in a:
    if ele%2!=0:
        count += 1
if sum(a[:n]) < a[-1]:
    print('NO')
if  count%2==0:
    print('YES')
else:
    print('NO')


n=int(input())
inp = input()
a=[int(ele) for ele in inp.split()]
a.sort()
count=0
for ele in a:
    if ele%2!=0:
        count += 1
if sum(a[:n-1]) < a[-1]:
    print('NO')
elif count%2==0:
    print('YES')
else:
    print('NO')


n=int(input())
inp = input()
a=[int(ele) for ele in inp.split()]
while len(a)>1:
    a.sort()
    a[-1] -= 1
    a[0] -= 1
    if a[0]==0:
        del a[0]
if a[0]==0:
    print('YES')
else:
    print('NO')


n = int(input())
l = [*map(int, input().split())]
print("l",l)
s = sum(l)
print(s&1)
m = max(l)
print("NO" if s & 1 or m > (s // 2) else "YES")


n = int(input())
l = [*map(int, input().split())]
s = sum(l)
m = max(l)
print("NO" if s & 1 or m > (s // 2) else "YES")


def check(l):
    s=sum(l)
    for i in l:
        if s-i<i:
            return "NO"
        if s%2:
            return "NO"
        else:
            return "YES"
n=int(input())
l=list(map(int,input().split()))
print(check(l))


N = int(input())
a = [int(i) for i in input().split()]
if(sum(a) % 2 == 0 and max(a) <= (sum(a)//2)):
    print("YES")
else:
    print("NO")


N = int(input())
cnt_odd = 0
maxx = 0
summ = 0
a = [int(x) for x in input().split()]
for i in a:
    if(i % 2 != 0):
        cnt_odd +=1
    if(i > maxx):
        maxx = i
    else:
        summ += i
if(cnt_odd % 2 == 0 and summ >= maxx):
    print("YES")
else:
    print("NO")


kol = input()
sp = list(map(int, input().split()))
sp1 = sp[:]
del sp[sp.index(max(sp))]
if max(sp) <= sum(sp) and sum(sp) % 2 == 0:
    print('YES')
else:
    print('NO')


kol = input()
sp = list(map(int, input().split()))
sp1 = sp[:]
del sp[sp.index(max(sp))]
if max(sp) <= sum(sp) and sum(sp1) % 2 == 0:
    print('YES')
else:
    print('NO')


N = int(input())
cnt_odd = 0
a = [int(x) for x in input().split()]
for i in a:
    if(i % 2 != 0):
        cnt_odd +=1
if(cnt_odd % 2 == 0):
    print("YES")
else:
    print("NO")


N = int(input())
cnt_odd = 0
maxx = 0
summ = 0
a = [int(x) for x in input().split()]
for i in a:
    if(i % 2 != 0):
        cnt_odd +=1
    if(i > maxx):
        maxx = i
    else:
        summ += i
if(cnt_odd % 2 == 0 and summ > maxx):
    print("YES")
else:
    print("NO")


N = int(input())
cnt_odd = 0
maxx = 0
su = 0
a = [int(x) for x in input().split()]
for i in a:
    if(i % 2 != 0):
        cnt_odd +=1
    if(i > maxx):
        maxx = i
    else:
        su += i
if(cnt_odd % 2 == 0 and su >= maxx):
    print("YES")
else:
    print("NO")


# Python3 program to split
# an array into Two
# equal sum subarrays

# Returns split point.
# If not possible,
# then return -1.
def findSplitPoint(arr, n) :
	# traverse array element and
	# compute sum of whole array
	leftSum = 0
	for i in range(0, n) :
		leftSum += arr[i]

	# again traverse array and
	# compute right sum and also
	# check left_sum equal to
	# right sum or not
	rightSum = 0
	for i in range(n-1, -1, -1) :
		# add current element
		# to right_sum
		rightSum += arr[i]

		# exclude current element
		# to the left_sum
		leftSum -= arr[i]

		if (rightSum == leftSum) :
			return i

	# if it is not possible
	# to split array into
	# two parts.
	return -1

# Prints two parts after
# finding split point
# using findSplitPoint()
def printTwoParts(arr, n) :
	splitPoint = findSplitPoint(arr, n)

	if (splitPoint == -1 or splitPoint == n ) :
		print ("NO")
		return
        else :
            print('YES')
            return;

# Driver Code
a=int(input())
z=list(map(int,input().split()))

printTwoParts(arr, a)

# This code is contributed by Manish Shaw
# (manishshaw1)


a=int(input())
z=list(map(int,input().split()))
if(sum(z)%2==0):
    print('YES')
else:
    print('NO')


a=int(input())
z=list(map(int,input().split()))
if(sum(z)%2==0 and max(z)<=sum(z)//2):
    print('YES')
else:
    print('NO')


a=int(input())
z=list(map(int,input().split()))
z.sort()
for i in range(1,len(z)):
    if(z[i]==z[i-1]):
        z[i]=0
        z[i-1]=0
    else:
        z[i]-=z[i-1]
        z[i-1]=0
if(z.count(0)==len(z)):
    print('YES')
else:
    print('NO')


# Problem: B. Zero Array
# Contest: Codeforces - Codeforces Round #577 (Div. 2)
# URL: https://codeforces.com/problemset/problem/1201/B
# Memory Limit: 256 MB
# Time Limit: 1000 ms
#
# KAPOOR'S

from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def MOD():
    return pow(10,9)+7

def OPS(ans):
	stdout.write(str(ans)+"\n")

def OPL(ans):
	[stdout.write(str(_)+" ") for _ in ans]
	stdout.write("\n")

if __name__=="__main__":
	n=INI()
	A=INL()
	m=max(A)
	s=sum(A)-m
	if sum(A)%2==0 and m<=s:
		OPS("YES")
	else:
		OPS("NO")


# Problem: B. Zero Array
# Contest: Codeforces - Codeforces Round #577 (Div. 2)
# URL: https://codeforces.com/problemset/problem/1201/B
# Memory Limit: 256 MB
# Time Limit: 1000 ms
#
# KAPOOR'S

from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def MOD():
    return pow(10,9)+7

def OPS(ans):
	stdout.write(str(ans)+"\n")

def OPL(ans):
	[stdout.write(str(_)+" ") for _ in ans]
	stdout.write("\n")

if __name__=="__main__":
	n=INI()
	if sum(INL())%2==0:
		OPS("YES")
	else:
		OPS("NO")


import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right,bisect
n=int(input())
a=list(map(int,stdin.readline().split()))
temp=sum(a)
if(temp%2==0):
    a.sort()
    if(a[-1]+a[-1]>temp):
        print("NO")
    else:
        print("YES")
else:
    print("NO")


import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right,bisect
n=int(input())
a=list(map(int,stdin.readline().split()))
if(sum(a)%2==0):
    print("YES")
else:
    print("NO")


# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!
# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!
# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!
from sys import stdin, stdout

N = int(input())
#s = input()
#N,M = [int(x) for x in stdin.readline().split()]
arr = [int(x) for x in stdin.readline().split()]

if sum(arr)%2==1:
    print('NO')
    quit()

arr.sort(reverse=True)

s = sum(arr)

for i in range(N-1):
    s -= arr[i]
    if arr[i]>s:
        print('NO')
        quit()

print('YES')


# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!
# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!
# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!
from sys import stdin, stdout

N = int(input())
#s = input()
#N,M = [int(x) for x in stdin.readline().split()]
arr = [int(x) for x in stdin.readline().split()]

s = sum(arr)

if (s-N)%2==0 or s%2==0:
    print('YES')
else:
    print('NO')


# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!
# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!
# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!
from sys import stdin, stdout

N = int(input())
#s = input()
#N,M = [int(x) for x in stdin.readline().split()]
arr = [int(x) for x in stdin.readline().split()]

if sum(arr)%2==1:
    print('NO')
    quit()

m = max(arr)

s = sum(arr)

if m>(s-m):
    print('NO')
else:
    print('YES')


import sys
input = sys.stdin.buffer.readline
def prog():
    n = int(input())
    nums = list(map(int,input().split()))
    total = 0
    for num in nums:
        total += num
    if 0 == num//2 % 2:
        print('YES')
    else:
        print('NO')
prog()


import sys
input = sys.stdin.buffer.readline
def prog():
    n = int(input())
    nums = list(map(int,input().split()))
    total = 0
    for num in nums:
        total += num
    if 0 == num % 2:
        fail = False
        for num in nums:
            if 2*num > total:
                fail = False
                break
        if fail:
            print('NO')
        else:
            print('YES')

    else:
        print('NO')
prog()


import sys
input = sys.stdin.buffer.readline
def prog():
    n = int(input())
    nums = list(map(int,input().split()))
    total = 0
    for num in nums:
        total += num
    if 0 == total % 2:
        fail = False
        for num in nums:
            if 2*num > total:
                fail = False
                break
        if fail:
            print('NO')
        else:
            print('YES')

    else:
        print('NO')
prog()


import sys
input = sys.stdin.buffer.readline
def prog():
    n = int(input())
    nums = list(map(int,input().split()))
    total = 0
    for num in nums:
        total += num
    if 0 == total % 2:
        fail = False
        for num in nums:
            if 2*num > total:
                fail = True
                break
        if fail:
            print('NO')
        else:
            print('YES')

    else:
        print('NO')
prog()


#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)

from collections import Counter
def main():
    n=int(input())
    a=list(map(int,input().split(" ")))
    print("YES" if sum([1 if x%2==0 else 0 for x in Counter(a).values()])==len(Counter(a)) else "NO")

#-----------------------------BOSS-------------------------------------!
# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)

from collections import Counter
def main():
    n=int(input())
    a=list(map(int,input().split(" ")))
    print("YES" if sum(a)%2==0 and max(a)<=sum(a)-max(a) else "NO")

#-----------------------------BOSS-------------------------------------!
# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)

from collections import Counter
def main():
    n=int(input())
    a=list(map(int,input().split(" ")))
    print("YES" if sum([1 if y>=2 else 0 for x,y in Counter(a).items()])==len(Counter(a)) else "NO")

#-----------------------------BOSS-------------------------------------!
# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


n=int(input())
a=list(map(int, input().split()))
if sum(a)%2==1:
  print('NO')
  exit()
else:
  a.sort(reverse=True)

  i=0
  while(i<n):
    j=i
    i+=1
    while(a[j]!=0 and i<n and j<n):
      #print(a)
      if a[i]<a[j]:
        a[j]-=a[i]
        a[i]=0
      elif a[j]==a[i]:
        a[j],a[i]=0,0
        i+=1
        break
      else:
        a[i]-=a[j]
        a[j]=0
        break
      i+=1

if a.count(0)==n:
  print('YES')
else: print('NO')


n=int(input())
a=list(map(int, input().split()))
if sum(a)%2==1:
  print('NO')
  exit()
else:
  a.sort(reverse=True)

  i=0
  while(i<n):
    j=i
    i+=1
    while(a[j]!=0 and i<n and j<n):
      #print(a)
      if a[i]<a[j]:
        a[j]-=a[i]
        a[i]=0
      elif a[j]==a[i]:
        a[j],a[i]=0,0
        i+=1
        break
      else:
        a[i]-=a[j]
        a[j]=0
        break
      i+=1
print(a)
if a.count(0)==n:
  print('YES')
else: print('NO')


n=int(input())
a=list(map(int, input().split()))
if sum(a)%2==1:
  print('NO')
  exit()
else:
  #a.sort(reverse=True)
  if (sum(a)-max(a))>=max(a):

    print('YES')
  else: print('NO')


n=int(input())
a=list(map(int, input().split()))
if sum(a)%2==1:
  print('NO')

else:
  print('YES')


n = int(input())
a = input()
A = list(map(int,list(a.split())))
if sum(A)%2 != 0:
    print("No")
else:
    if max(A)<=sum(A)-max(A):
        print("Yes")
    else:
        print("No")


n = int(input())
a = input()
A = list(map(int,list(a.split())))
if sum(A)%2 == 0:
    print("Yes")
else:
    print("No")


n = int(input())
arr = list(map(int,input().split()))
s = sum(arr)
arr.sort()
if s%2!=0:
	print("NO")
else:
	last = arr[-1]
	s = s-last
	if last<=s:
		print("YES")
	else:
		print("NO")


n = int(input())
arr = list(map(int,input().split()))
odd = []
even = []
for i in arr:
	if i%2!=0:
		odd.append(i)
	else:
		even.append(i)
odd.sort()
even.sort()
if len(odd)>1:
	for i in range(1,len(odd)):
		odd[i]-=odd[i-1]
	odd[0] = 0
	t = 0
	for i in odd:
		if i!=0:
			t = i
else:
	t = odd[0]
if t%2!=0:
	print("NO")
else:
	if t!=0:
		even.append(t)
	even.sort()
	for i in range(1,len(even)):
		even[i]-=even[i-1]
	even[0] = 0
	f = 0
	for i in even:
		if i!=0:
			f = 1
			break
	if f==1:
		print("NO")
	else:
		print("YES")


n = int(input())
arr = list(map(int,input().split()))
s = sum(arr)
if s%2!=0:
	print("NO")
else:
	print("YES")


n = int(input())
arr = list(map(int,input().split()))
odd = []
even = []
for i in arr:
	if i%2!=0:
		odd.append(i)
	else:
		even.append(i)
odd.sort()
even.sort()
if len(odd)>1:
	for i in range(1,len(odd)):
		odd[i]-=odd[i-1]
	odd[0] = 0
	t = 0
	for i in odd:
		if i!=0:
			t = i
elif len(odd)==1:
	t = odd[0]
elif len(odd)==0:
	t = 0

if t%2!=0:
	print("NO")
else:
	if t!=0:
		even.append(t)
	even.sort()
	if len(even)>1:
		for i in range(1,len(even)):
			even[i]-=even[i-1]
		even[0] = 0
		f = 0
		for i in even:
			if i!=0:
				f = 1
				break
		if f==1:
			print("NO")
		else:
			print("YES")
	elif t==0:
		print("YES")
	else:
		print("NO")


n = int(input())
arr = list(map(int,input().split()))
s = sum(arr)
if s%2!=0:
	print("NO")
else:
	last = arr[-1]
	s = s-last
	if last<=s:
		print("YES")
	else:
		print("NO")


n = int(input())

a = list(map(int, input().split()))

if sum(a)%2 != 0:
    print('NO')

else:
    a.sort(reverse=True)
    if a[0] > sum(a[1:]):
        print('NO')
    else:
        while len(a) > 1:
            while a[0] >= a[1]:
                a[0] -= a[1]
                a.pop(1)
                if len(a) <= 1:
                    break
            if a[0] == 0:
                a.pop(0)
            else:
                a[1] -= a[0]
                a.pop(0)

        if len(a) == 1:
            print('NO')
        else:
            print('YES')


n = int(input())

a = list(map(int, input().split()))

a.sort(reverse=True)

while len(a) > 1:
    if a[0] > a[1]:
        a[0] -= a[1]
        a.pop(1)
    elif a[0] == a[1]:
        a.pop(0)
        a.pop(0)
    elif a[0] < a[1]:
        a[1] -= a[0]
        a.pop(0)

if len(a) == 1:
    print("NO")
else:
    print('YES')


n = int(input())

a = list(map(int, input().split()))

if sum(a) % 2 != 0:
    print('NO')

else:
    if a[0] > sum(a[1:]):
        print('NO')
    else:
        a.sort(reverse=True)

        while len(a) > 1:
            while a[0] > a[1]:
                a[0] -= a[1]
                a.pop(1)
                if len(a) <= 1:
                    break
            if len(a) > 1:
                if a[0] == a[1]:
                    a.pop(0)
                    a.pop(0)
                else:
                    start = 0
                    end = len(a)
                    while start <= end:
                        mid = (start + end)//2
                        if a[0] < a[mid]:
                            start = mid + 1
                        elif a[0] > a[mid]:
                            end = mid - 1
                        else:
                            a.insert(mid, a[0])
                            a.pop(0)
                            break
                    else:
                        a.insert(start, a[0])
                        a.pop(0)
            print(a)
        if len(a) == 1 and a[0] != 0:
            print('NO')
        else:
            print('YES')


n = int(input())

a = list(map(int, input().split()))

if sum(a)%2 != 0:
    print('NO')

else:
    a.sort(reverse=True)
#     # if a[0] > sum(a[1:]):
#     #     print('NO')
#     # else:
#     #
    while len(a) > 1:
        while a[0] > a[1]:
            a[0] -= a[1]
            a.pop(1)
            if len(a) <= 1:
                break
        if a[0] == a[1]:
            a.pop(0)
            a.pop(0)
        else:
            start = 0
            end = len(a)
            while start <= end:
                mid = (start + end)//2
                if a[0] < a[mid]:
                    start = mid + 1
                elif a[0] > a[mid]:
                    end = mid - 1
                else:
                    a.insert(mid, a[0])
                    a.pop(0)
                    break
            else:
                a.insert(start, a[0])
                a.pop(0)
    if len(a) == 1 and a[0] != 0:
        print('NO')
    else:
        print('YES')


n = int(input())

a = list(map(int, input().split()))

if sum(a) % 2 != 0:
    print('NO')

else:
    if a[0] > sum(a[1:]):
        print('NO')
    else:
        print('YES')

        # a.sort(reverse=True)
        #
        # while len(a) > 1:
        #     # print(a)
        #     while a[0] > a[1]:
        #         a[0] -= a[1]
        #         a.pop(1)
        #         if len(a) <= 1:
        #             break
        #     if len(a) > 1:
        #         if a[0] == a[1]:
        #             a.pop(0)
        #             a.pop(0)
        #         else:
        #             start = 0
        #             end = len(a) - 1
        #             while start <= end:
        #                 mid = (start + end)//2
        #                 if a[0] < a[mid]:
        #                     start = mid + 1
        #                 elif a[0] > a[mid]:
        #                     end = mid - 1
        #                 else:
        #                     a.insert(mid, a[0])
        #                     a.pop(0)
        #                     break
        #             else:
        #                 a.insert(start, a[0])
        #                 a.pop(0)
        #
        # if len(a) == 1 and a[0] != 0:
        #     print('NO')
        # else:
        #     print('YES')


n = int(input())

a = list(map(int, input().split()))

if sum(a) % 2 != 0:
    print('NO')

else:
    if a[0] > sum(a[1:]):
        print('NO')
    else:
        a.sort(reverse=True)

        while len(a) > 1:
            # print(a)
            while a[0] > a[1]:
                a[0] -= a[1]
                a.pop(1)
                if len(a) <= 1:
                    break
            if len(a) > 1:
                if a[0] == a[1]:
                    a.pop(0)
                    a.pop(0)
                else:
                    start = 0
                    end = len(a) - 1
                    while start <= end:
                        mid = (start + end)//2
                        if a[0] < a[mid]:
                            start = mid + 1
                        elif a[0] > a[mid]:
                            end = mid - 1
                        else:
                            a.insert(mid, a[0])
                            a.pop(0)
                            break
                    else:
                        a.insert(start, a[0])
                        a.pop(0)

        if len(a) == 1 and a[0] != 0:
            print('NO')
        else:
            print('YES')


n = int(input())

a = list(map(int, input().split()))

if sum(a)%2 != 0:
    print('NO')

else:
    if a[0] > sum(a[1:]):
        print('NO')
    else:
        print('YES')
    # a.sort(reverse=True)
    #
    # while len(a) > 1:
    #     if a[0] > a[1]:
    #         a[0] -= a[1]
    #         a.pop(1)
    #     elif a[0] == a[1]:
    #         a.pop(0)
    #         a.pop(0)
    #     elif a[0] < a[1]:
    #         a[1] -= a[0]
    #         a.pop(0)
    #
    # if len(a) == 1:
    #     print("NO")
    # else:
    #     print('YES')


n = int(input())

a = list(map(int, input().split()))

if sum(a) % 2 != 0:
    print('NO')

else:
    a.sort(reverse=True)
    if a[0] > sum(a[1:]):
        print('NO')
    else:
        print('YES')


n = int(input())

a = list(map(int, input().split()))

if sum(a)%2 != 0:
    print('NO')

else:
    a.sort(reverse=True)
    if a[0] > sum(a[1:]):
        print('NO')
    else:
        while len(a) > 1:
            while a[0] >= a[1]:
                a[0] -= a[1]
                a.pop(1)
                if len(a) <= 1:
                    break
            if a[0] == 0:
                a.pop(0)
            else:
                a[1] -= a[0]
                a.pop(0)

        if len(a) == 1 and a[0] != 0:
            print('NO')
        else:
            print('YES')


n = int(input())

a = list(map(int, input().split()))

if sum(a) % 2 != 0:
    print('NO')

else:
    if a[0] > sum(a[1:]):
        print('NO')
    else:
        a.sort(reverse=True)

        while len(a) > 1:
            while a[0] > a[1]:
                a[0] -= a[1]
                a.pop(1)
                if len(a) <= 1:
                    break
            if len(a) > 1:
                if a[0] == a[1]:
                    a.pop(0)
                    a.pop(0)
                else:
                    start = 0
                    end = len(a)
                    while start <= end:
                        mid = (start + end)//2
                        if a[0] < a[mid]:
                            start = mid + 1
                        elif a[0] > a[mid]:
                            end = mid - 1
                        else:
                            a.insert(mid, a[0])
                            a.pop(0)
                            break
                    else:
                        a.insert(start, a[0])
                        a.pop(0)
            # print(a)
        if len(a) == 1 and a[0] != 0:
            print('NO')
        else:
            print('YES')


n=int(input())
a=list(map(int,input().split()))
if sum(a)%2==0 and max(a)<=sum(a)/2:
    print("YES")
else:
    print("NO")


n=int(input())
a=list(map(int.input().split()))
if sum(a)%2==0 and max(a)<=sum(a)/2:
    print("YES")
else:
    print("NO")


n=int(input())
a=list(map(int,input().split()))
if sum(a)%2==0 and max(a)<=sum(a)/2:
    print("YES"+"")
else:
    print("NO")


MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n=ii()
l=il()
print("NO" if sum(l)%2 or max(l)>sum(l)-max(l) else "YES")


MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n=ii()
l=sorted(il())
for i in range(1,n):
    l[i]-=l[i-1]
print('NO' if l[-1] else 'YES')


n=int(input())
a=[int(i) for i in input().split()]
sum=0
for i in range(0,len(a)):
    sum=sum+a[i]
if(sum%2==0):
    print('YES')
else:
    print('NO')


n=int(input())
a=[int(i) for i in  input().split()]
s=[]
d=0
for i in range(0,len(a)):
    s.append(a[i]-0)
c=set(s)
if(len(c)==1):
    print("YES")
elif(len(c)==2):
    for i in c:
        if(s.count(i)%2==0):
            d=d+1
    if(d==2):
        print("YES")
    else:
        print("NO")

else:
    print("NO")


n=int(input())
a=[int(i) for i in input().split()]
sum=0
for i in range(0,len(a)):
    sum=sum+a[i]
d=max(a)
sums=sum-d
if(sum%2==0 and (d<=sums)):
    print('YES')
else:
    print('NO')


n=int(input())
a=[int(i) for i in  input().split()]
s=set()
for i in range(0,len(a)):
    if((a[i]-0) not in s):
        s.add(a[i])
    else:
        pass
if(len(s)<=2):
    print("YES")
else:
    print("NO")


n = int(input())
l = list(map(int,input().split()))

l.sort()

z = sum(l)
if z%2 == 0:
    if z ==l[-1] or z == 2*l[-1]:
     print('YES')
    else:
     print('NO')
else:
    print('NO')


n = int(input())
l = list(map(int,input().split()))

z = sum(l)
if z%2 == 0:
    if sum(l[:-1]) >=l[-1]:
      print('YES')
    else:
      print('NO')
else:
    print('NO')


n = int(input())
l = list(map(int,input().split()))

l.sort()

z = sum(l)
if z%2 == 0:
    print('YES')
else:
    print('NO')


n = int(input())
l = list(map(int,input().split()))

l.sort()

z = sum(l)
if z%2 == 0:
    if sum(l[:len(l)-1]) == 2*l[-1] or sum(l[:len(l)-1]) == l[-1] :
     print('YES')
    else:
     print('NO')
else:
    print('NO')


from collections import defaultdict
n = int(input())
l = list(map(int,input().split()))

hash = defaultdict(int)

l.sort()

for i in l:
    hash[i]+=1
ans = l

if ans == []:
    print('YES')
else:
    z = sum(ans)
    if len(set(ans)) == 1:
      if len(ans)%2 == 0:
        print('YES')
      else:
          print('NO')
    elif z%2!=0:
        print('NO')
    else:
        ans.sort()
        if sum(ans[:len(ans)-1]) == ans[-1]:
            print('YES')
        else:
            print('NO')


n = int(input())
l = list(map(int,input().split()))

z = sum(l)
if z%2 == 0:
    if sum(l[:len(l)-1]) >=l[-1]:
     print('YES')
    else:
     print('NO')
else:
    print('NO')


from collections import defaultdict
n = int(input())
l = list(map(int,input().split()))

hash = defaultdict(int)

l.sort()

for i in l:
    hash[i]+=1
ans = []
for i in hash:
    if hash[i]%2!=0:
        ans.append(i)

if ans == []:
    print('YES')
else:
    z = sum(ans)
    if len(ans) == 1:
        print('NO')
    elif z%2!=0:
        print('NO')
    else:
        # ans.sort()
        # if sum(ans[:len(ans)-1]) == ans[-1]:
        #     print('YES')
        # else:
        #     print('NO')
        print('YES')


from collections import defaultdict
n = int(input())
l = list(map(int,input().split()))

hash = defaultdict(int)

l.sort()

for i in l:
    hash[i]+=1
ans = []
for i in hash:
    if hash[i]%2!=0:
        ans.append(i)

if ans == []:
    print('YES')
else:
    z = sum(ans)
    if len(ans) == 1:
        print('NO')
    elif z%2!=0:
        print('NO')
    else:
        ans.sort()
        if sum(ans[:len(ans)-1]) == ans[-1]:
            print('YES')
        else:
            print('NO')


n = int(input())
l = list(map(int,input().split()))

l.sort()

z = sum(l)
if z%2 == 0:
    if sum(l[:-1]) >=l[-1]:
      print('YES')
    else:
      print('NO')
else:
    print('NO')


n = int(input())
l = list(map(int,input().split()))

l.sort()

z = sum(l)
if z%2 == 0:
    if z ==l[-1] or z == 2*l[-1] or sum(l[:len(l)-1]) == 2*l[-1] or sum(l[:len(l)-1]) == l[-1] :
     print('YES')
    else:
     print('NO')
else:
    print('NO')


from collections import defaultdict
n = int(input())
l = list(map(int,input().split()))

hash = defaultdict(int)

l.sort()

for i in l:
    hash[i]+=1
ans = []
for i in hash:
    if hash[i]%2!=0:
        ans.append(i)

if ans == []:
    print('YES')
else:
    l.sort()
    ans.sort()
    z1 =sum(l)
    z2 = sum(ans)
    if sum(l)%2!=0:
        print('NO')
    elif sum(ans[:len(ans)-1]) == ans[-1]:
        print('YES')
    elif sum(l[:len(l)-1]) == l[-1]:
        print('YES')
    else:
        print('NO')


from sys import stdin
###############################################################
def iinput(): return int(stdin.readline())
def minput(): return map(int, stdin.readline().split())
def linput(): return list(map(int, stdin.readline().split()))
###############################################################

from collections import Counter

n = iinput()
a = linput()
c = Counter(a)
for e in c:
    if c[e]&1 and e&1:
        print('NO')
        break
else:
    print('YES')


from sys import stdin
###############################################################
def iinput(): return int(stdin.readline())
def minput(): return map(int, stdin.readline().split())
def linput(): return list(map(int, stdin.readline().split()))
###############################################################

from collections import Counter

n = iinput()
a = linput()
c = Counter(a)
for e in c:
    if c[e]&1:
        print('NO')
        break
else:
    print('YES')


n=int(input())
a=list(map(int,input().split()))
x=sum(a);
m=max(a);
if m<=x-m and x%2==0:
    print('YES')
else:
    print("NO")


n=int(input())
a=list(map(int,input().split()))
x=sum(a);
m=max(a);
if m<=x-m and sum%2==0:
    print('YES')
else:
    print("NO")


#!/usr/bin/env python
# https://github.com/cheran-senthil/PyRival/blob/master/templates/template_py3.py
import os
import sys,math
from io import BytesIO, IOBase

def main():
    t=1
    for case in range(t):
        n=int(input())
        l=list(map(int,input().split()))
        if max(l)<=(sum(l)-max(l)) and sum(l)%2==0: print("YES")
        else: print("NO")

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env python
# https://github.com/cheran-senthil/PyRival/blob/master/templates/template_py3.py
import os
import sys,math
from io import BytesIO, IOBase

def main():
    t=1
    for case in range(t):
        n=int(input())
        l=list(map(int,input().split()))
        if max(l)<=n and sum(l)%2==0: print("YES")
        else: print("NO")

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
using namespace std;
int n;
struct node{
	int v,w,sz;
	node *l,*r;
	long long sum[5];
	void maintain(){
		int pre=0,s=1;
		if(l!=NULL)s+=l->sz;
		pre=s;
		if(r!=NULL)s+=r->sz;
		sz=s;
		set0(sum);
		sum[(pre%5)]=v;
		for(int i=0;i<5;i++){
			if(l!=NULL)sum[i]+=l->sum[i];
			if(r!=NULL)sum[(pre+i)%5]+=r->sum[i];
		}
	}
	node(int x){
		this->v=x;
		this->w=rand();
		this->sz=1;
		this->l=this->r=NULL;
		set0(sum);
		this->sum[1]=x;
	}
};
node* rt;
void Split(node *x,node **l,node **r,int v){
	if(x==NULL)(*l)=(*r)=NULL;
	else if(x->v<v){
		*l=x;
		Split(x->r,&x->r,r,v);
	}
	else{
		*r=x;
		Split(x->l,l,&x->l,v);
	}
	if((*l)!=NULL)(*l)->maintain();
	if((*r)!=NULL)(*r)->maintain();
}
void Merge(node **x,node *l,node *r){
	if(l==NULL || r==NULL){
		*x=(l==NULL)?r:l;
		return;
	}
	if(l->w<r->w){
		*x=l;
		Merge(&(*x)->r,(*x)->r,r);
	}
	else{
		*x=r;
		Merge(&(*x)->l,l,(*x)->l);
	}
	if((*x)!=NULL)(*x)->maintain();
}
void add(node **x,int v){
	node *l,*r,*m;
	Split(*x,&l,&r,v);
	Merge(&m,l,new node(v));
	Merge(x,m,r);
}
void del(node **x,int v){
	node *l,*m,*r,*tmp;
	Split(*x,&l,&tmp,v);
	Split(tmp,&m,&r,v+1);
	Merge(x,l,r);
}
int main(){
	srand((unsigned)time(NULL));
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	rt=new node(INF);
	node* Null=rt;
	while(n--){
		string opt;
		cin>>opt;
		if(opt[0]=='s'){
			if(rt==Null)cout<<"0\n";
			else cout<<(rt->sum[3])<<endl;
		}
		else{
			int x;
			cin>>x;
			if(opt[0]=='a')add(&rt,x);
			else del(&rt,x);
		}
	}
	return 0;
}


#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
using namespace std;
int n;
struct node{
	int v,w,sz;
	node *l,*r;
	long long sum[5];
	void maintain(){
		int pre=0,s=1;
		if(l!=NULL)s+=l->sz;
		pre=s;
		if(r!=NULL)s+=r->sz;
		sz=s;
		set0(sum);
		sum[(pre%5)]=v;
		for(int i=0;i<5;i++){
			if(l!=NULL)sum[i]+=l->sum[i];
			if(r!=NULL)sum[(pre+i)%5]+=r->sum[i];
		}
	}
	node(int x){
		this->v=x;
		this->w=rand();
		this->sz=1;
		this->l=this->r=NULL;
		set0(sum);
		this->sum[1]=x;
	}
};
node* rt;
void Split(node *x,node **l,node **r,int v){
	if(x==NULL)(*l)=(*r)=NULL;
	else if(x->v<v){
		*l=x;
		Split(x->r,&x->r,r,v);
	}
	else{
		*r=x;
		Split(x->l,l,&x->l,v);
	}
	if((*l)!=NULL)(*l)->maintain();
	if((*r)!=NULL)(*r)->maintain();
}
void Merge(node **x,node *l,node *r){
	if(l==NULL || r==NULL){
		*x=(l==NULL)?r:l;
		return;
	}
	if(l->w<r->w){
		*x=l;
		Merge(&(*x)->r,(*x)->r,r);
	}
	else{
		*x=r;
		Merge(&(*x)->l,l,(*x)->l);
	}
	if((*x)!=NULL)(*x)->maintain();
}
void add(node **x,int v){
	node *l,*r,*m;
	Split(*x,&l,&r,v);
	Merge(&m,l,new node(v));
	Merge(x,m,r);
}
void del(node **x,int v){
	node *l,*m,*r,*tmp;
	Split(*x,&l,&tmp,v);
	Split(tmp,&m,&r,v+1);
	Merge(x,l,r);
}
int main(){
	srand((unsigned)time(NULL));
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	rt=new node(INF);
	while(n--){
		string opt;
		cin>>opt;
		if(opt[0]=='s'){
			if(rt==NULL)cout<<"0\n";
			else cout<<(rt->sum[3])<<endl;
		}
		else{
			int x;
			cin>>x;
			if(opt[0]=='a')add(&rt,x);
			else del(&rt,x);
		}
	}
	return 0;
}


#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EPS 1e-10
#define set0(x) memset((x),0,sizeof(x))
#define setINF(x) memset((x),63,sizeof(x))
using namespace std;
int n;
struct node{
	int v,w,sz;
	node *l,*r;
	long long sum[5];
	void maintain(){
		int pre=0,s=1;
		if(l!=NULL)s+=l->sz;
		pre=s;
		if(r!=NULL)s+=r->sz;
		sz=s;
		set0(sum);
		sum[(pre%5)]=v;
		for(int i=0;i<5;i++){
			if(l!=NULL)sum[i]+=l->sum[i];
			if(r!=NULL)sum[(pre+i)%5]+=r->sum[i];
		}
	}
	node(int x){
		this->v=x;
		this->w=rand();
		this->sz=1;
		this->l=this->r=NULL;
		set0(sum);
		this->sum[1]=x;
	}
};
node* rt;
void Split(node *x,node **l,node **r,int v){
	if(x==NULL)(*l)=(*r)=NULL;
	else if(x->v<v){
		*l=x;
		Split(x->r,&x->r,r,v);
	}
	else{
		*r=x;
		Split(x->l,l,&x->l,v);
	}
	if((*l)!=NULL)(*l)->maintain();
	if((*r)!=NULL)(*r)->maintain();
}
void Merge(node **x,node *l,node *r){
	if(l==NULL || r==NULL){
		*x=(l==NULL)?r:l;
		return;
	}
	if(l->w<r->w){
		*x=l;
		Merge(&(*x)->r,(*x)->r,r);
	}
	else{
		*x=r;
		Merge(&(*x)->l,l,(*x)->l);
	}
	if((*x)!=NULL)(*x)->maintain();
}
void add(node **x,int v){
	node *l,*r,*m;
	Split(*x,&l,&r,v);
	Merge(&m,l,new node(v));
	Merge(x,m,r);
}
void del(node **x,int v){
	node *l,*m,*r,*tmp;
	Split(*x,&l,&tmp,v);
	Split(tmp,&m,&r,v+1);
	Merge(x,l,r);
}
int main(){
	srand((unsigned)time(NULL));
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	while(n--){
		string opt;
		cin>>opt;
		if(opt[0]=='s'){
			if(rt==NULL)cout<<"0\n";
			else cout<<(rt->sum[3])<<endl;
		}
		else{
			int x;
			cin>>x;
			if(opt[0]=='a'){
				if(rt==NULL)rt=new node(x);
				else add(&rt,x);
			}
			else del(&rt,x);
		}
	}
	return 0;
}