{"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\"\u003eThe city planners plan to build N plants in the city which has M shops.\u003cbr\u003e\u003cbr\u003eEach shop needs products from some plants to make profit of $pro_i$ units.\u003cbr\u003e\u003cbr\u003e Building ith plant needs investment of $pay_i$ units and it takes $t_i$ days.\u003cbr\u003e\u003cbr\u003eTwo or more plants can be built simultaneously, so that the time for building multiple plants is maximum of their periods($t_i$).\u003cbr\u003e\u003cbr\u003eYou should make a plan to make profit of at least L units in the shortest period.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"First line contains T, a number of test cases.\u003cbr\u003e\u003cbr\u003eFor each test case, there are three integers N, M, L described above.\u003cbr\u003e\u003cbr\u003eAnd there are N lines and each line contains two integers $pay_i$, $t_i$(1\u0026lt;\u003d i \u0026lt;\u003d N).\u003cbr\u003e\u003cbr\u003eLast there are M lines and for each line, first integer is $pro_i$, and there is an integer k and next k integers are index of plants which can produce material to make profit for the shop.\u003cbr\u003e\u003cbr\u003e1 \u0026lt;\u003d T \u0026lt;\u003d 30\u003cbr\u003e1 \u0026lt;\u003d N, M \u0026lt;\u003d 200\u003cbr\u003e$1 \\leq L, t_i \\leq 1000000000$\u003cbr\u003e$1 \\leq pay_i, pro_i \\leq 30000$\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, first line contains a line “Case #x: t p”, x is the number of the case, t is the shortest period and p is maximum profit in t hours. You should minimize t first and then maximize p.\u003cbr\u003e\u003cbr\u003eIf this plan is impossible, you should print “Case #x: impossible”\u003cbr\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\u003e2\r\n\r\n1 1 2\r\n1 5\r\n3 1 1\r\n\r\n1 1 3\r\n1 5\r\n3 1 1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1: 5 2\r\nCase #2: impossible\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}