{"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\"\u003eYou have a big farm, and you want to grow vegetables in it. You\u0027re too lazy to seed the seeds yourself, so you\u0027ve hired n people to do the job for you.\u003cbr\u003eEach person works in a rectangular piece of land, seeding one seed in one unit square. The working areas of different people may overlap, so one unit square can be seeded several times. However, due to limited space, different seeds in one square fight each other -- finally, the most powerful seed wins. If there are several \"most powerful\" seeds, one of them win (it does not matter which one wins).\u003cbr\u003e\u003cbr\u003eThere are m kinds of seeds. Different seeds grow up into different vegetables and sells for different prices. \u003cbr\u003eAs a rule, more powerful seeds always grow up into more expensive vegetables.\u003cbr\u003eYour task is to calculate how much money will you get, by selling all the vegetables in the whole farm.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains a single integer T (T \u0026lt;\u003d 10), the number of test cases. \u003cbr\u003eEach case begins with two integers n, m (1 \u0026lt;\u003d n \u0026lt;\u003d 30000, 1 \u0026lt;\u003d m \u0026lt;\u003d 3).\u003cbr\u003eThe next line contains m distinct positive integers p\u003csub\u003ei\u003c/sub\u003e (1 \u0026lt;\u003d p\u003csub\u003ei\u003c/sub\u003e \u0026lt;\u003d 100), the prices of each kind of vegetable. \u003cbr\u003eThe vegetables (and their corresponding seeds) are numbered 1 to m in the order they appear in the input. \u003cbr\u003eEach of the following n lines contains five integers x1, y1, x2, y2, s, indicating a working seeded a rectangular area with lower-left corner (x1,y1), upper-right corner (x2,y2), with the s-th kind of seed.\u003cbr\u003eAll of x1, y1, x2, y2 will be no larger than 10\u003csup\u003e6\u003c/sup\u003e in their absolute values."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, print the case number and your final income."}},{"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\u003e2\r\n1 1\r\n25\r\n0 0 10 10 1\r\n2 2\r\n5 2\r\n0 0 2 1 1\r\n1 0 3 2 2\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase 1: 2500\r\nCase 2: 16\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}