{"trustable":false,"prependHtml":"\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 async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"MD","content":"Alice 和 Bob 在玩猜拳游戏。\n\nBob 比较蠢,所以接下来的 $n$ 轮,Bob 会出什么手势,Alice 已经提前猜到了。\n\n为此,Bob 给 Alice 下了 $m$ 个限制,诸如:\n* ``i j 0`` 表示第 i 轮和第 j 轮 Alice 要出的手势必须相同;\n* ``i j 1`` 表示第 i 轮和第 j 轮 Alice 可以出的手势必须不同。\n\n问满足限制的情况下,Alice 是否仍然可以立于不报之地。\n\n---\n\n\u003cdiv class\u003d\"panel_content\"\u003e\n Conflicts are everywhere in the world, from the young to the elderly, from families to countries. Conflicts cause quarrels, fights or even wars. How wonderful the world will be if all conflicts can be eliminated.\n \u003cbr\u003e\n Edward contributes his lifetime to invent a \u0027Conflict Resolution Terminal\u0027 and he has finally succeeded. This magic item has the ability to eliminate all the conflicts. It works like this:\n \u003cbr\u003e\n If any two people have conflict, they should simply put their hands into the \u0027Conflict Resolution Terminal\u0027 (which is simply a plastic tube). Then they play \u0027Rock, Paper and Scissors\u0027 in it. After they have decided what they will play, the tube should be opened and no one will have the chance to change. Finally, the winner have the right to rule and the loser should obey it. Conflict Eliminated!\n \u003cbr\u003e\n But the game is not that fair, because people may be following some patterns when they play, and if the pattern is founded by others, the others will win definitely.\n \u003cbr\u003e\n Alice and Bob always have conflicts with each other so they use the \u0027Conflict Resolution Terminal\u0027 a lot. Sadly for Bob, Alice found his pattern and can predict how Bob plays precisely. She is very kind that doesn\u0027t want to take advantage of that. So she tells Bob about it and they come up with a new way of eliminate the conflict:\n \u003cbr\u003e\n They will play the \u0027Rock, Paper and Scissors\u0027 for N round. Bob will set up some restricts on Alice.\n \u003cbr\u003e\n But the restrict can only be in the form of \"you must play the same (or different) on the ith and jth rounds\". If Alice loses in any round or break any of the rules she loses, otherwise she wins.\n \u003cbr\u003e\n Will Alice have a chance to win?\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"MD","content":"The first line contains an integer T(1 \u0026lt;\u003d T \u0026lt;\u003d 50), indicating the number of test cases.\n\u003cbr\u003e\nEach test case contains several lines.\n\u003cbr\u003e\nThe first line contains two integers N,M(1 \u0026lt;\u003d N \u0026lt;\u003d 10000, 1 \u0026lt;\u003d M \u0026lt;\u003d 10000), representing how many round they will play and how many restricts are there for Alice.\n\u003cbr\u003e\nThe next line contains N integers B\u003csub\u003e1\u003c/sub\u003e,B\u003csub\u003e2\u003c/sub\u003e, ...,B\u003csub\u003eN\u003c/sub\u003e, where B\u003csub\u003ei\u003c/sub\u003e represents what item Bob will play in the i\u003csup\u003eth\u003c/sup\u003e round. 1 represents Rock, 2 represents Paper, 3 represents Scissors.\n\u003cbr\u003e\nThe following M lines each contains three integers A,B,K(1 \u0026lt;\u003d A,B \u0026lt;\u003d N,K \u003d 0 or 1) represent a restrict for Alice. If K equals 0, Alice must play the same on A\u003csup\u003eth\u003c/sup\u003e and B\u003csup\u003eth\u003c/sup\u003e round. If K equals 1, she must play different items on Ath and Bthround."}},{"title":"Output","value":{"format":"MD","content":"For each test case in the input, print one line: \"Case #X: Y\", where X is the test case number (starting with 1) and Y is \"yes\" or \"no\" represents whether Alice has a chance to win."}},{"title":"Sample","value":{"format":"MD","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\u003e\u003cpre\u003e2\n3 3\n1 1 1\n1 2 1\n1 3 1\n2 3 1\n5 5\n1 2 3 2 1\n1 2 1\n1 3 1\n1 4 1\n1 5 1\n2 3 0\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e\u003cpre\u003eCase #1: no\nCase #2: yes\u003c/pre\u003e\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"MD","content":"\u003cbr\u003e\n\u0027Rock, Paper and Scissors\u0027 is a game which played by two person. They should play Rock, Paper or Scissors by their hands at the same time. \n\u003cbr\u003e\nRock defeats scissors, scissors defeats paper and paper defeats rock. If two people play the same item, the game is tied..\n\u003cbr\u003e"}}]}