{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cp\u003eThere are 3 kinds of animals A, B and C. A can eat B, B can eat C, C can eat A. It\u0027s interesting, isn\u0027t it?\u003c/p\u003e\r\n\u003cp\u003eNow we have n animals, numbered from 1 to n. Each of them is one of the 3 kinds of animals: A, B, C.\u003c/p\u003e\r\n\u003cp\u003eToday Mary tells us k pieces of information about these n animals. Each piece has one of the two forms below:\r\n\u003c/p\u003e\u003cul\u003e\r\n\u003cli\u003e1 x y: It tells us the kind of x and y are the same.\u003c/li\u003e\r\n\u003cli\u003e2 x y: It tells us x can eat y.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003cp\u003eSome of these k pieces are true, some are false. The piece is false if it satisfies one of\r\nthe 3 conditions below, otherwise it\u0027s true.\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eX or Y in this piece is larger than n.\u003c/li\u003e\r\n\u003cli\u003eThis piece tells us X can eat X.\u003c/li\u003e\r\n\u003cli\u003eThis piece conflicts to some true piece before.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\r\n\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eThe first line contains a single integer t. t blocks follow.\u003c/p\u003e\r\n\u003cp\u003eFor every block, the first line contains two integers n (1 \u0026lt;\u003d n \u0026lt;\u003d 50000) and k (1 \u0026lt;\u003d k \u0026lt;\u003d 100000).\r\nk lines follow, each contains 3 positive integers D (1 \u0026lt;\u003d D \u0026lt;\u003d 2), X, Y, separated by single spaces.\u003c/p\u003e\r\n\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eOutput t lines, each contains a single integer - the number of false pieces in the corresponding block.\u003c/p\u003e\r\n\r\n\u003ch3\u003eExample\u003c/h3\u003e\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\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\u003e1\r\n100 7\r\n1 101 1\r\n2 1 2\r\n2 2 3\r\n2 3 3\r\n1 1 3\r\n2 3 1\r\n1 5 5\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\r\n\r\n\u003ch4\u003eHint\u003c/h4\u003e\r\n\u003cp\u003eThe false pieces are the 1st, the 4th and the 5th ones.\u003c/p\u003e\r\n\u003cb\u003eWarning: large Input/Output data, be careful with certain languages.\u003c/b\u003e\n\u003c/div\u003e"}}]}