{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"The CE digital company has built an Automatic Painting Machine (APM) to paint a flat board fully covered by adjacent non-overlapping rectangles of different sizes each with a predefined color.\r\u003cbr\u003e\u003ccenter\u003e\u003cimg src\u003d\"CDN_BASE_URL/dd0c5a824365fae70ef9c301363ba303?v\u003d1714996151\"\u003e\u003c/center\u003e\r\u003cbr\u003eTo color the board, the APM has access to a set of brushes. Each brush has a distinct color C. The APM picks one brush with color C and paints all possible rectangles having predefined color C with the following restrictions:\r\u003cbr\u003eTo avoid leaking the paints and mixing colors, a rectangle can only be painted if all rectangles immediately above it have already been painted. For example rectangle labeled F in Figure 1 is painted only after rectangles C and D are painted. Note that each rectangle must be painted at once, i.e. partial painting of one rectangle is not allowed.\r\u003cbr\u003eYou are to write a program for APM to paint a given board so that the number of brush pick-ups is minimum. Notice that if one brush is picked up more than once, all pick-ups are counted.\r\u003cbr\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input file contains an integer M which is the number of test cases to solve (1 \u0026lt;\u003d M \u0026lt;\u003d 10). For each test case, the first line contains an integer N, the number of rectangles, followed by N lines describing the rectangles. Each rectangle R is specified by 5 integers in one line: the y and x coordinates of the upper left corner of R, the y and x coordinates of the lower right corner of R, followed by the color-code of R.\r\u003cbr\u003eNote that: \r\u003cbr\u003e\u003col\u003e\u003cli\u003eColor-code is an integer in the range of 1 .. 20.\r\u003cbr\u003e\u003c/li\u003e\u003cli\u003eUpper left corner of the board coordinates is always (0,0).\r\u003cbr\u003e\u003c/li\u003e\u003cli\u003eCoordinates are in the range of 0 .. 99.\r\u003cbr\u003e\u003c/li\u003e\u003cli\u003eN is in the range of 1..15.\u003c/li\u003e\u003c/ol\u003e\r\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"One line for each test case showing the minimum number of brush pick-ups. "}},{"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\u003e1\r\n7\r\n0 0 2 2 1\r\n0 2 1 6 2\r\n2 0 4 2 1\r\n1 2 4 4 2\r\n1 4 3 6 1\r\n4 0 6 4 1\r\n3 4 6 6 2\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"}}]}