{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\u003cdiv\u003e\u003cp\u003eWindy has a country, and he wants to build an army to protect his country. He has picked up \u003ci\u003eN\u003c/i\u003e girls and \u003ci\u003eM\u003c/i\u003e boys and wants to collect them to be his soldiers. To collect a soldier without any privilege, he must pay 10000 RMB. There are some relationships between girls and boys and Windy can use these relationships to reduce his cost. If girl \u003cb\u003ex\u003c/b\u003e and boy \u003cb\u003ey\u003c/b\u003e have a relationship \u003ci\u003ed\u003c/i\u003e and one of them has been collected, Windy can collect the other one with 10000-\u003ci\u003ed\u003c/i\u003e RMB. Now given all the relationships between girls and boys, your assignment is to find the least amount of money Windy has to pay. Notice that only one relationship can be used when collecting one soldier. \u003c/p\u003e\u003c/div\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003e\u003cdiv\u003e\u003cp\u003eThe first line of input is the number of test case.\u003cbr\u003eThe first line of each test case contains three integers, \u003ci\u003eN\u003c/i\u003e, \u003ci\u003eM\u003c/i\u003e and \u003ci\u003eR\u003c/i\u003e.\u003cbr\u003eThen \u003ci\u003eR\u003c/i\u003e lines followed, each contains three integers \u003ci\u003ex\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e, \u003ci\u003ey\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e and \u003ci\u003ed\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e.\u003cbr\u003eThere is a blank line before each test case.\u003cbr\u003e\u003c/p\u003e\u003cp\u003e1 ≤ \u003ci\u003eN\u003c/i\u003e, \u003ci\u003eM\u003c/i\u003e ≤ 100000000000\u003cbr\u003e0 ≤ \u003ci\u003eR\u003c/i\u003e ≤ 50,000,000,000,000\u003cbr\u003e0 ≤ \u003ci\u003ex\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e \u0026lt; \u003ci\u003eN\u003c/i\u003e\u003cbr\u003e0 ≤ \u003ci\u003ey\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e \u0026lt; \u003ci\u003eM\u003c/i\u003e\u003cbr\u003e0 \u0026lt; \u003ci\u003ed\u003csub\u003ei\u003c/sub\u003e\u003c/i\u003e \u0026lt; 10,000,000,000\u003cbr\u003e\u003c/p\u003e\u003c/div\u003e\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"ptx\" lang\u003d\"en-US\"\u003eFor each test case output the answer in a single line.\u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e2\n\n5 5 8\n4 3 6831\n1 3 4583\n0 0 6592\n0 1 3063\n3 3 4975\n1 3 2049\n4 2 2104\n2 2 781\n\n5 5 10\n2 4 9820\n3 2 6236\n3 1 8864\n2 4 8326\n2 0 5156\n2 0 1463\n4 1 2439\n0 4 4373\n3 4 8889\n2 4 3133\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre class\u003d\"sio\"\u003e71071\n54223\n\u003c/pre\u003e"}},{"title":"","value":{"format":"HTML","content":""}}]}