{"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\"\u003eBaby volcano is now at a robotic class. In this class, babies are required to program a special control system of a robot. This control system has a real-valued control variable $x$, which captures the behavior of this robot. In addition, this control system could be abstracted as an acyclic directed graph, with $n$ node, the nodes are indexed from $1$ to $n$. In this graph, the node $n$ has no output edge, termed as the output node. Moreover, for each vertex $t,1\\leq t\u0026lt;n$, there is a number $k_t$, a set of $integer$-$valued$ limits $a_{t,0}\u0026lt;a_{t,1}\u0026lt;a_{t,2}\u0026lt;\\cdots\u0026lt;a_{t,k_{t}-1}\u0026lt;a_{t,k_t}:\u003d+\\infty$, and a set of $integer$-$valued$ coefficients, bias and destinations $c_{t,0},b_{t,0},d_{t,0} ,c_{t,1},b_{t,1},d_{t,1},c_{t,2},b_{t,2},d_{t,2}\\cdots,c_{t,k_t},b_{t,k_t},d_{t,k_t}$. For every $t$ and $i, 0\\leq i\\leq k_t$, $-1\\leq c_{t,i}\\leq 1$.\u003cbr\u003e\u003cbr\u003eTo use this system to control the robot, the user follows the steps below:\u003cbr\u003e\u003cbr\u003e1. Choose $x_0$ and initialize $x:\u003dx_0$, then choose some node $s_0$ and set the currect node $t:\u003ds_0$\u003cbr\u003e2. If $t$ is the output node$(t\u003dn)$, then output $x_{out}:\u003dx$, else go to step 3.\u003cbr\u003e3. The user finds the smallest $i$ such that $a_{t,i}\\geq x$(Note that $i$ always exists), then transform $x:\u003dc_{t,i}\\times x+b_{t,i}$, and set $t:\u003dd_{t,i}$, and go back to step 2.\u003cbr\u003e\u003cbr\u003eNote that for every fixed $s_0$, the output value $x_{out}$ is a function with respect to the initial value $x_0\\in \\mathbb R$, we call this function $C_{s_0}(x_0)$.\u003cbr\u003e\u003cbr\u003eTo precisely control the robot, it is required that for every initial node $s_0$, $C_{s_0}(x_0)$ is continuous with respect to $x_0$.\u003cbr\u003e\u003cbr\u003eA function $f(x),x\\in \\mathbb R$ is continuous with respect to $x$ iff \u003cbr\u003e$$\\forall x\\in \\mathbb R,\\forall \\epsilon\u0026gt;0,\\exists \\delta\u0026gt;0,\\forall x\u0027\\in \\mathbb R, (|x-x\u0027|\\leq \\delta \\implies |f(x)-f(x\u0027)|\\leq \\epsilon)$$\u003cbr\u003e\u003cbr\u003eYou need to verify this requirement is satisfied or not. In other words, if for every initial node $s_0$, $C_{s_0}(x_0)$ is continuous with respect to $x_0$, you should output \u0027\u0027YES\u0027\u0027. If there exists some node $s^*$ such that $C_{s^*}(x_0)$ is not continuous, you should output \u0027\u0027NO\u0027\u0027.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"In the first line there is one integer $T$, denotes the number of test cases.\u003cbr\u003e\u003cbr\u003eThe rest of input has $T$ part, each part corresponds to a test case.\u003cbr\u003e\u003cbr\u003eFor each part, in the first line there is a number $n$, denotes the number of nodes.\u003cbr\u003e\u003cbr\u003eIn the next $n-1$ lines, the $i$-th line starts with $k_i$, follows with $4k_i+3$ integers, they are $c_{i,0},b_{i,0},d_{i,0},a_{i,0},c_{i,1},b_{i,1},d_{i,1},a_{i,1},\\cdots, a_{i,k_i-1},c_{i,k_i},b_{i,k_i},d_{i,k_i}$.\u003cbr\u003e\u003cbr\u003eIt guarantees that $1\\leq T\\leq 100$,\u003cbr\u003eand in a single test cases,\u003cbr\u003e$1\\leq n\\leq 500$,\u003cbr\u003e$1\\leq \\sum{k_i}\\leq 2000$,\u003cbr\u003e$-1\\leq c_{i,j}\\leq 1$,\u003cbr\u003e$-10^6\\leq b_{i,j}\\leq 10^6$,\u003cbr\u003e$-10^9\\leq a_{i,j}\\leq 10^9$,\u003cbr\u003e$i+1\\leq d_{i,j}\\leq n$.\u003cbr\u003eAnd it guarantees that $a_{i,j-1}\u0026lt;a_{i,j}$ for every $1\\leq j\u0026lt; k_i$."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, you should firstly output \u0027\u0027Case #t: \u0027\u0027(without quotes), where $t$ is the index of this test case, then if for every initial node $s_0$, $C_{s_0}(x_0)$ is continuous with respect to $x_0$, you should output \u0027\u0027YES\u0027\u0027. If there exists some node $s^*$ such that $C_{s^*}(x_0)$ is not continuous, you should output \u0027\u0027NO\u0027\u0027."}},{"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\n4\r\n1 1 1 2 -4 -1 -7 3\r\n0 -1 -2 4\r\n0 1 4 4\r\n4\r\n1 1 1 2 -4 -1 -7 3\r\n0 -1 -3 4\r\n0 1 4 4\r\n1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1: YES\r\nCase #2: NO\r\nCase #3: YES\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}