{"trustable":true,"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":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eLittle Q loves playing with different kinds of graphs very much. One day he thought about an interesting category of graphs called ``Cool Graph\u0027\u0027, which are generated in the following way:\u003cbr\u003eLet the set of vertices be {1, 2, 3, ..., $n$}. You have to consider every vertice from left to right (i.e. from vertice 2 to $n$). At vertice $i$, you must make one of the following two decisions:\u003cbr\u003e(1) Add edges between this vertex and all the previous vertices (i.e. from vertex 1 to $i-1$).\u003cbr\u003e(2) Not add any edge between this vertex and any of the previous vertices.\u003cbr\u003eIn the mathematical discipline of graph theory, a matching in a graph is a set of edges without common vertices. A perfect matching is a matching that each vertice is covered by an edge in the set.\u003cbr\u003eNow Little Q is interested in checking whether a \u0027\u0027Cool Graph\u0027\u0027 has perfect matching. Please write a program to help him.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input contains an integer $T(1\\leq T\\leq50)$, denoting the number of test cases.\u003cbr\u003eIn each test case, there is an integer $n(2\\leq n\\leq 100000)$ in the first line, denoting the number of vertices of the graph.\u003cbr\u003eThe following line contains $n-1$ integers $a_2,a_3,...,a_n(1\\leq a_i\\leq 2)$, denoting the decision on each vertice."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output a string in the first line. If the graph has perfect matching, output \u0027\u0027Yes\u0027\u0027, otherwise output \u0027\u0027No\u0027\u0027.\u003cbr\u003e"}},{"title":"Sample","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\r\n2\r\n1\r\n2\r\n2\r\n4\r\n1 1 2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYes\r\nNo\r\nNo\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}