Abhishek wants to go for a ride in a new spaceship on the eve of CODE IN SPACE CHALLENGE. The spaceship contains w words and has relations amongst some of them. Now there's something very interesting about these relations. Particularly, the relations are of two kinds, a synonym (words having similar meaning) and antonym (words having opposite meaning) relation.
Abhishek also knows that if two words have relation among themselves, there are other relations also connecting these two particular words with relations with other words on the spaceship. For example, if a word happy has a synonym relation with word joyful and an antonym relation with the word sad, it implies that there is an antonym relation between joyful and sad also.
Since Abhishek thinks a lot, especially about his girlfriend, he sometimes imagines a few relations by observing some of the relations laid down in the space ship. Some of these are absolutely wrong. For example, if he sees a synonym relation between the words happy and joyful and an antonym relation between happy and sad, he imagines in his mind that there also exists a synonym relation between joyful and sad which is absolutely wrong.
And he asks his girlfriend to verify these relations in order. If there doesn't exist such a relation, he skips it, else, he writes this as a next relation.
Also his space project guide comes and asks a series of queries for two distinct words. He has to answer them whether they are connected or not, and if they are connected, by a synonym or an antonym relation.
As his girlfriend is too busy organising the Dhishna Techfest, only you can come to Abhishek's rescue.
The first line of input contains three integers, w , m and q, where w is the number of words in the spaceship, m are the relations defined on two particular words and q are the number of queries asked by the project guide.
The second line consists of w distinct words, w1,w2,w3...wn consisting of lowercase words in English language, whose length doesn't exceed 20, which are the words on the spaceship.
Then m lines follow, each of which consist of an integer t, followed by two different words xi and yi which appears in the spaceship. If t=1, it means that there is a synonym relation between the two words and if t=2, it denotes an antonym relation.
Then q lines follow, which are the queries asked by the guide, each of which consists of two words. This is the query that needs to be done.
In all relations and queries, the two words are different.
Constraints
Firstly, print m separate lines, each stating whether the relation is valid or not. If it is, print "YES", else print "NO", without quotes.
Now print q different lines, each for a query asked. Print 1 if they hold a synonym relation, 2 if they hold an antonym relation and 3 if neither holds.
Abhishek thinks about 3 relations in his mind, out of which, 2 are correct and the third one is invalid.
Also, all the queries given in the test cases have either synonym or antonym relations.