{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eMahmoud wants to write a new dictionary that contains \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/span\u003e words and relations between them. There are two types of relations: synonymy (i.\u0026nbsp;e. the two words mean the same) and antonymy (i.\u0026nbsp;e. the two words mean the opposite). From time to time he discovers a new relation between two words.\u003c/p\u003e\n\u003cp\u003eHe know that if two words have a relation between them, then each of them has relations with the words that has relations with the other. For example, if \u003cspan class\u003d\"tex-font-style-tt\"\u003elike\u003c/span\u003e means \u003cspan class\u003d\"tex-font-style-tt\"\u003elove\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003elove\u003c/span\u003e is the opposite of \u003cspan class\u003d\"tex-font-style-tt\"\u003ehate\u003c/span\u003e, then \u003cspan class\u003d\"tex-font-style-tt\"\u003elike\u003c/span\u003e is also the opposite of \u003cspan class\u003d\"tex-font-style-tt\"\u003ehate\u003c/span\u003e. One more example: if \u003cspan class\u003d\"tex-font-style-tt\"\u003elove\u003c/span\u003e is the opposite of \u003cspan class\u003d\"tex-font-style-tt\"\u003ehate\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003ehate\u003c/span\u003e is the opposite of \u003cspan class\u003d\"tex-font-style-tt\"\u003elike\u003c/span\u003e, then \u003cspan class\u003d\"tex-font-style-tt\"\u003elove\u003c/span\u003e means \u003cspan class\u003d\"tex-font-style-tt\"\u003elike\u003c/span\u003e, and so on.\u003c/p\u003e\n\u003cp\u003eSometimes Mahmoud discovers a wrong relation. A wrong relation is a relation that makes two words equal and opposite at the same time. For example if he knows that \u003cspan class\u003d\"tex-font-style-tt\"\u003elove\u003c/span\u003e means \u003cspan class\u003d\"tex-font-style-tt\"\u003elike\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003elike\u003c/span\u003e is the opposite of \u003cspan class\u003d\"tex-font-style-tt\"\u003ehate\u003c/span\u003e, and then he figures out that \u003cspan class\u003d\"tex-font-style-tt\"\u003ehate\u003c/span\u003e means \u003cspan class\u003d\"tex-font-style-tt\"\u003elike\u003c/span\u003e, the last relation is absolutely wrong because it makes \u003cspan class\u003d\"tex-font-style-tt\"\u003ehate\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003elike\u003c/span\u003e opposite and have the same meaning at the same time.\u003c/p\u003e\n\u003cp\u003eAfter Mahmoud figured out many relations, he was worried that some of them were wrong so that they will make other relations also wrong, so he decided to tell every relation he figured out to his coder friend Ehab and for every relation he wanted to know is it correct or wrong, basing on the previously discovered relations. If it is wrong he ignores it, and doesn\u0027t check with following relations.\u003c/p\u003e\n\u003cp\u003eAfter adding all relations, Mahmoud asked Ehab about relations between some words based on the information he had given to him. Ehab is busy making a Codeforces round so he asked you for help.\u003c/p\u003e\n马哈茂德想写一本包含n个单词以及它们之间的关系的新词典。有两种关系:同义词(即两个词的意思相同)和反义词(即两个词的意思相反)。他不时地发现两个词之间的新联系。\u003cbr\u003e\u003cbr\u003e\n\n\n\n他知道,如果两个词之间有联系,那么每一个词与另一个词之间就有联系。例如,如果喜欢是爱的意思,而爱是恨的反义词,那么喜欢也是恨的反义词。再举一个例子:如果爱是恨的反义词,而恨是喜欢的反义词,那么爱就是喜欢,等等。\u003cbr\u003e\u003cbr\u003e\n\n\n\n有时马哈茂德会发现错误的关系。错误的关系是指使两个词同时相等又相反的关系。例如,如果他知道爱的意思是喜欢,而喜欢是恨的反义词,然后他发现恨的意思是喜欢,最后一种关系是绝对错误的,因为它使恨和喜欢对立,同时具有相同的含义。\u003cbr\u003e\u003cbr\u003e\n\n\n\n马哈茂德·找出许多关系后,他担心其中一些是错误的,这样他们会让其他关系也错了,所以他决定告诉他发现编码器每关系的朋友Ehab每关系他想知道是正确的还是错误的,基于之前发现的关系。如果是错误的,他就忽略它,并且不检查下面的关系。\u003cbr\u003e\u003cbr\u003e\n\n\n\n在加上所有的关系之后,马哈茂德根据他给他的信息询问了一些词语之间的关系。伊哈卜正忙着进行代码力测试所以他找你帮忙。\u003cbr\u003e\u003cbr\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line of input contains three integers \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/span\u003e, \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003em\u003c/i\u003e\u003c/span\u003e and \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eq\u003c/i\u003e\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e2 ≤ \u003ci\u003en\u003c/i\u003e ≤ 10\u003csup class\u003d\"upper-index\"\u003e5\u003c/sup\u003e\u003c/span\u003e, \u003cspan class\u003d\"tex-span\"\u003e1 ≤ \u003ci\u003em\u003c/i\u003e, \u003ci\u003eq\u003c/i\u003e ≤ 10\u003csup class\u003d\"upper-index\"\u003e5\u003c/sup\u003e\u003c/span\u003e) where \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/span\u003e is the number of words in the dictionary, \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003em\u003c/i\u003e\u003c/span\u003e is the number of relations Mahmoud figured out and \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eq\u003c/i\u003e\u003c/span\u003e is the number of questions Mahmoud asked after telling all relations.\u003c/p\u003e\n\u003cp\u003eThe second line contains \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/span\u003e distinct words \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ea\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e1\u003c/sub\u003e, \u003ci\u003ea\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e2\u003c/sub\u003e, ..., \u003ci\u003ea\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003en\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e consisting of small English letters with length not exceeding \u003cspan class\u003d\"tex-span\"\u003e20\u003c/span\u003e, which are the words in the dictionary.\u003c/p\u003e\n\u003cp\u003eThen \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003em\u003c/i\u003e\u003c/span\u003e lines follow, each of them contains an integer \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003et\u003c/i\u003e\u003c/span\u003e (\u003cspan class\u003d\"tex-span\"\u003e1 ≤ \u003ci\u003et\u003c/i\u003e ≤ 2\u003c/span\u003e) followed by two different words \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ex\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e and \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ey\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e which has appeared in the dictionary words. If \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003et\u003c/i\u003e \u003d 1\u003c/span\u003e, that means \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ex\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e has a synonymy relation with \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ey\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e, otherwise \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ex\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e has an antonymy relation with \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003ey\u003c/i\u003e\u003csub class\u003d\"lower-index\"\u003e\u003ci\u003ei\u003c/i\u003e\u003c/sub\u003e\u003c/span\u003e.\u003c/p\u003e\n\u003cp\u003eThen \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eq\u003c/i\u003e\u003c/span\u003e lines follow, each of them contains two different words which has appeared in the dictionary. That are the pairs of words Mahmoud wants to know the relation between basing on the relations he had discovered.\u003c/p\u003e\n\u003cp\u003eAll words in input contain only lowercase English letters and their lengths don\u0027t exceed \u003cspan class\u003d\"tex-span\"\u003e20\u003c/span\u003e characters. In all relations and in all questions the two words are different.\u003c/p\u003e\n输入的第一行包含三个整数n, m和q(2≤n≤105、1≤m q≤105)其中n是单词在字典里的数量,m是马哈茂德·发现的数量关系,q是艾哈迈迪在告诉所有被问到的问题的数量关系。\u003cbr\u003e\u003cbr\u003e\n\n\n\n第二行包含n个不同的单词a1, a2,…,由英文小字母组成,长度不超过20,是字典中的单词。\n\u003cbr\u003e\u003cbr\u003e\n\n\n然后后面有m行,每一行包含一个整数t(1≤t≤2),后面跟着两个不同的单词xi和yi,它们在字典中出现过。如果t \u003d 1,这意味着xi和yi是同义关系,否则xi和yi是反义关系。\u003cbr\u003e\u003cbr\u003e\n\n\n\n然后q行,每一行包含两个在字典中出现过的不同单词。这就是马哈茂德根据他发现的关系想要知道的单词对之间的关系。\u003cbr\u003e\u003cbr\u003e\n\n\n\n所有输入的单词只包含小写英文字母,其长度不超过20个字符。在所有的关系和问题中,这两个词都是不同的。\u003cbr\u003e\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFirst, print \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003em\u003c/i\u003e\u003c/span\u003e lines, one per each relation. If some relation is wrong (makes two words opposite and have the same meaning at the same time) you should print \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eNO\u003c/span\u003e\" (without quotes) and ignore it, otherwise print \"\u003cspan class\u003d\"tex-font-style-tt\"\u003eYES\u003c/span\u003e\" (without quotes).\u003c/p\u003e\n\u003cp\u003eAfter that print \u003cspan class\u003d\"tex-span\"\u003e\u003ci\u003eq\u003c/i\u003e\u003c/span\u003e lines, one per each question. If the two words have the same meaning, output \u003cspan class\u003d\"tex-span\"\u003e1\u003c/span\u003e. If they are opposites, output \u003cspan class\u003d\"tex-span\"\u003e2\u003c/span\u003e. If there is no relation between them, output \u003cspan class\u003d\"tex-span\"\u003e3\u003c/span\u003e.\u003c/p\u003e\n\u003cp\u003eSee the samples for better understanding.\u003c/p\u003e\n首先,打印m行,每个关系一行。如果一些关系是错误的(使两个词相反,同时有相同的意思),你应该打印“NO”(不带引号)并忽略它,否则打印“YES”(不带引号)。\u003cbr\u003e\u003cbr\u003e\n\n然后输出q行,每个问题一个。如果这两个单词的意思相同,则输出1。如果它们是相反的,输出2。如果两者之间没有关联,则输出3。\u003cbr\u003e\u003cbr\u003e\n\n请参阅示例以获得更好的理解。\u003cbr\u003e\u003cbr\u003e"}},{"title":"Sample 1","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3 3 4\nhate love like\n1 love like\n2 love hate\n1 hate like\nlove like\nlove hate\nlike hate\nhate like\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYES\nYES\nNO\n1\n2\n2\n2\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Sample 2","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e8 6 5\nhi welcome hello ihateyou goaway dog cat rat\n1 hi welcome\n1 ihateyou goaway\n2 hello ihateyou\n2 hi goaway\n2 hi hello\n1 hi hello\ndog cat\ndog hi\nhi hello\nihateyou goaway\nwelcome ihateyou\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYES\nYES\nYES\nYES\nNO\nYES\n3\n3\n1\n1\n2\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}