{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cimg src\u003d\"CDN_BASE_URL/b28847b151944006c6035f99ee5a4956?v\u003d1714996131\" align\u003d\"right\" hspace\u003d\"10\"\u003e\u003cspan lang\u003d\"en-us\"\u003e\u003cp\u003eWhile visiting a traveling fun fair you suddenly have an urge to break the high score in the Whac-a-Mole game. The goal of the Whac-a-Mole game is to… well… whack moles. With a hammer. To make the job easier you have first consulted the fortune teller and now you know the exact appearance patterns of the moles.\u003c/p\u003e\u003cp\u003eThe moles appear out of holes occupying the \u003ci\u003en\u003c/i\u003e\u003csup\u003e2\u003c/sup\u003e integer points (\u003ci\u003ex\u003c/i\u003e, \u003ci\u003ey\u003c/i\u003e) satisfying 0 ≤ \u003ci\u003ex\u003c/i\u003e, \u003ci\u003ey\u003c/i\u003e \u0026lt; \u003ci\u003en\u003c/i\u003e in a two-dimensional coordinate system. At each time step, some moles will appear and then disappear again before the next time step. After the moles appear but before they disappear, you are able to move your hammer in a straight line to any position (\u003ci\u003ex\u003c/i\u003e\u003csub\u003e2\u003c/sub\u003e, \u003ci\u003ey\u003c/i\u003e\u003csub\u003e2\u003c/sub\u003e) that is at distance at most d from your current position (\u003ci\u003ex\u003c/i\u003e\u003csub\u003e1\u003c/sub\u003e, \u003ci\u003ey\u003c/i\u003e\u003csub\u003e1\u003c/sub\u003e). For simplicity, we assume that you can only move your hammer to a point having integer coordinates. A mole is whacked if the center of the hole it appears out of is located on the line between (\u003ci\u003ex\u003c/i\u003e\u003csub\u003e1\u003c/sub\u003e, \u003ci\u003ey\u003c/i\u003e\u003csub\u003e1\u003c/sub\u003e) and (\u003ci\u003ex\u003c/i\u003e\u003csub\u003e2\u003c/sub\u003e, \u003ci\u003ey\u003c/i\u003e\u003csub\u003e2\u003c/sub\u003e) (including the two endpoints). Every mole whacked earns you a point. When the game starts, before the first time step, you are able to place your hammer anywhere you see fit.\u003c/p\u003e\u003c/span\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cspan lang\u003d\"en-us\"\u003e\u003cp\u003eThe input consists of several test cases. Each test case starts with a line containing three integers \u003ci\u003en\u003c/i\u003e, \u003ci\u003ed\u003c/i\u003e and \u003ci\u003em\u003c/i\u003e, where \u003ci\u003en\u003c/i\u003e and \u003ci\u003ed\u003c/i\u003e are as described above, and \u003ci\u003em\u003c/i\u003e is the total number of moles that will appear (1 ≤ \u003ci\u003en\u003c/i\u003e ≤ 20, 1 ≤ \u003ci\u003ed\u003c/i\u003e ≤ 5, and 1 ≤ \u003ci\u003em\u003c/i\u003e ≤ 1000). Then follow \u003ci\u003em\u003c/i\u003e lines, each containing three integers \u003ci\u003ex\u003c/i\u003e, \u003ci\u003ey\u003c/i\u003e and \u003ci\u003et\u003c/i\u003e giving the position and time of the appearance of a mole (0 ≤ \u003ci\u003ex\u003c/i\u003e, \u003ci\u003ey\u003c/i\u003e \u0026lt; \u003ci\u003en\u003c/i\u003e and 1 ≤ \u003ci\u003et\u003c/i\u003e ≤ 10). No two moles will appear at the same place at the same time.\u003c/p\u003e\u003cp\u003eThe input is ended with a test case where \u003ci\u003en\u003c/i\u003e \u003d \u003ci\u003ed\u003c/i\u003e \u003d \u003ci\u003em\u003c/i\u003e \u003d 0. This case should not be processed.\u003c/p\u003e\u003c/span\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each test case output a single line containing a single integer, the maximum possible score achievable.\u003c/p\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\u003e4 2 6\r\n0 0 1\r\n3 1 3\r\n0 1 2\r\n0 2 2\r\n1 0 2\r\n2 0 2\r\n5 4 3\r\n0 0 1\r\n1 2 1\r\n2 4 1\r\n0 0 0\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\r\n2\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}