{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003clink href\u003d\"css/light_oj.css\" rel\u003d\"stylesheet\" type\u003d\"text/css\" /\u003e\r\n\u003cp class\u003d\"MsoNormal\"\u003e\r\n\t\u0026#39;Wishing Snake\u0026#39; is a computer game for children. In this game, there is a big board and a snake. The board contains 1000 check points numbered from 0 to 999. And the snake can go from any checkpoint to another without crossing other checkpoints. Initially the snake is at checkpoint 0.\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNormal\"\u003e\r\n\tNow \u003cb\u003en\u003c/b\u003e children come in front of the board and they start to wish. Each wish is like \u0026quot;I want to see the snake walking from checkpoint \u003cb\u003eu\u003c/b\u003e to checkpoint \u003cb\u003ev\u003c/b\u003e.\u0026quot; And the snake can fulfill this wish by walking from checkpoint \u003cb\u003eu\u003c/b\u003e to checkpoint \u003cb\u003ev\u003c/b\u003e without crossing any other checkpoints. Each child can have multiple wishes. At first a child comes in front of the board and makes his wishes. After that a new child comes and makes his new wishes (that means not wished by any children yet). And it continues until the nth children.\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNormal\"\u003e\r\n\tAfter that the snake starts walking from one checkpoint to another. It can only walk from one checkpoint to another if any child had wished it. The snake wants to fulfill all the wishes done by all the children in one single path. Since you are the main designer of the game; you want to find whether it\u0026#39;s possible or not.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp class\u003d\"MsoNormal\"\u003e\r\n\tInput starts with an integer \u003cb\u003eT (\u003c/b\u003e\u003cb\u003e\u0026le; 65)\u003c/b\u003e, denoting the number of test cases.\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNormal\"\u003e\r\n\tEach case starts with an integer \u003cb\u003en (1 \u0026le; n \u0026le; 100)\u003c/b\u003e. Then for each child an integer \u003cb\u003ek (k \u0026ge; 0)\u003c/b\u003e is given. Each of the next \u003cb\u003ek\u003c/b\u003e lines contains two integers \u003cb\u003eu v (0 \u0026le; u, v \u0026lt; 1000, u \u0026ne; v)\u003c/b\u003e denoting that the child wants to see the snake going from checkpoint \u003cb\u003eu\u003c/b\u003e to checkpoint \u003cb\u003ev\u003c/b\u003e. You may assume that all the wishes are distinct and correct. And the total number of wishes in any case is between \u003cb\u003e1\u003c/b\u003e and \u003cb\u003e10000\u003c/b\u003e (inclusive).\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp class\u003d\"MsoNormal\"\u003e\r\n\tFor each case, print the case number and \u003cb\u003e\u0026#39;YES\u0026#39;\u003c/b\u003e if it\u0026#39;s possible, otherwise print \u003cb\u003e\u0026#39;NO\u0026#39;\u003c/b\u003e.\u003c/p\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cp class\u003d\"MsoNoSpacing\"\u003e\r\n\t\u003cspan style\u003d\"font-family:\u0026quot;Courier New\u0026quot;\"\u003e2\u003c/span\u003e\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNoSpacing\"\u003e\r\n\t\u003cspan style\u003d\"font-family:\u0026quot;Courier New\u0026quot;\"\u003e2\u003c/span\u003e\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNoSpacing\"\u003e\r\n\t\u003cspan style\u003d\"font-family:\u0026quot;Courier New\u0026quot;\"\u003e2\u003c/span\u003e\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNoSpacing\"\u003e\r\n\t\u003cspan style\u003d\"font-family:\u0026quot;Courier New\u0026quot;\"\u003e0 9\u003c/span\u003e\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNoSpacing\"\u003e\r\n\t\u003cspan style\u003d\"font-family:\u0026quot;Courier New\u0026quot;\"\u003e9 10\u003c/span\u003e\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNoSpacing\"\u003e\r\n\t\u003cspan style\u003d\"font-family:\u0026quot;Courier New\u0026quot;\"\u003e1\u003c/span\u003e\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNoSpacing\"\u003e\r\n\t\u003cspan style\u003d\"font-family:\u0026quot;Courier New\u0026quot;\"\u003e10 15\u003c/span\u003e\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNoSpacing\"\u003e\r\n\t\u003cspan style\u003d\"font-family:\u0026quot;Courier New\u0026quot;\"\u003e1\u003c/span\u003e\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNoSpacing\"\u003e\r\n\t\u003cspan style\u003d\"font-family:\u0026quot;Courier New\u0026quot;\"\u003e2\u003c/span\u003e\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNoSpacing\"\u003e\r\n\t\u003cspan style\u003d\"font-family:\u0026quot;Courier New\u0026quot;\"\u003e0 9\u003c/span\u003e\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNoSpacing\"\u003e\r\n\t\u003cspan style\u003d\"font-family:\u0026quot;Courier New\u0026quot;\"\u003e0 11\u003c/span\u003e\u003c/p\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cp class\u003d\"MsoNoSpacing\"\u003e\r\n\t\u003cspan style\u003d\"font-family:\u0026quot;Courier New\u0026quot;\"\u003eCase 1: YES\u003c/span\u003e\u003c/p\u003e\r\n\u003cp class\u003d\"MsoNoSpacing\"\u003e\r\n\t\u003cspan style\u003d\"font-family:\u0026quot;Courier New\u0026quot;\"\u003eCase 2: NO\u003c/span\u003e\u003c/p\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cp\u003e\r\n\tGraph theory\u003c/p\u003e"}}]}