{"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":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003e\n Little 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:\n \u003cbr\u003e\n Let 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:\n \u003cbr\u003e\n (1) Add edges between this vertex and all the previous vertices (i.e. from vertex 1 to $i-1$).\n \u003cbr\u003e\n (2) Not add any edge between this vertex and any of the previous vertices.\n \u003cbr\u003e\n In 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.\n \u003cbr\u003e\n Now Little Q is interested in checking whether a \u0027\u0027Cool Graph\u0027\u0027 has perfect matching. Please write a program to help him.\n \u003cbr\u003e\n\u003c/div\u003e\n\u003cbr\u003e\n小Q非常喜欢玩各种各样的图形。有一天,他想到了一个有趣的图表类别,叫做“Cool Graph”,它是通过以下方式生成的:\u003cbr\u003e\n设顶点集合为{1,2,3,…,n}。你必须从左到右对每个顶点(即从顶点2到n进行操作)。在顶点i,你必须做出以下两个决定之一:\u003cbr\u003e\n(1)在该顶点和之前所有顶点之间添加边(即从顶点1到i−1)。\u003cbr\u003e\n(2)不在这个顶点和之前的任何顶点之间添加任何边\u003cbr\u003e\n在图论的数学学科中,一个图中的匹配是一组没有公共顶点的边。完美匹配是指集合中每个顶点都被一条边覆盖的匹配。\u003cbr\u003e\n现在小Q有兴趣检查“Cool Graph”是否有完美匹配。请写一个程序来帮助他。"}},{"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.\n\u003cbr\u003e\nIn 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.\n\u003cbr\u003e\nThe following line contains $n-1$ integers $a_2,a_3,...,a_n(1\\leq a_i\\leq 2)$, denoting the decision on each vertice.\n\u003cbr\u003e\n输入的第一行包含一个整数T(1≤T≤50),表示测试用例的数量。\u003cbr\u003e\n在每个测试用例中,第一行有一个整数n(2≤n≤100000),表示图的顶点数。\u003cbr\u003e\n下一行包含n−1个整数a2,a3,…,an(1≤ai≤2),表示在每个顶点上的操作。"}},{"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.\n\u003cbr\u003e\n对于每个测试用例,在第一行输出一个字符串。如果图形完全匹配,输出“Yes”,否则输出“No”。"}},{"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\n2\n1\n2\n2\n4\n1 1 2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYes\nNo\nNo\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}