{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"\u003ch3\u003eRead problems statements in \u003ca target\u003d\"_blank\" \nhref\u003d\"https://www.codechef.com/download/translated/NOV17/mandarin/POLY.pdf\"\u003eMandarin chinese\u003c/a\u003e, \u003ca target\u003d\"_blank\" \nhref\u003d\"https://www.codechef.com/download/translated/NOV17/russian/POLY.pdf\"\u003eRussian\u003c/a\u003e and \u003ca target\u003d\"_blank\" \nhref\u003d\"https://www.codechef.com/download/translated/NOV17/vietnamese/POLY.pdf\"\u003eVietnamese\u003c/a\u003e as well.\u003c/h3\u003e\n\n\u003cp\u003eGiven \u003cb\u003en\u003c/b\u003e functions \u003cb\u003ey\u003csub\u003ei\u003c/sub\u003e(x) \u003d a\u003csub\u003e0\u003c/sub\u003e\n + a\u003csub\u003e1\u003c/sub\u003ex + a\u003csub\u003e2\u003c/sub\u003ex\u003csup\u003e2\u003c/sup\u003e + a\u003csub\u003e3\u003c/sub\u003ex\u003csup\u003e3\u003c/sup\u003e\u003c/b\u003e and \u003cb\u003eq\u003c/b\u003e queries. For each query, you are given an integer \u003cb\u003et\u003c/b\u003e and you are required to find out \u003cb\u003ey\u003csub\u003ei\u003c/sub\u003e\u003c/b\u003e (\u003cb\u003ei ≤ i \u0026le; n\u003c/b\u003e) that minimizes the value of \u003cb\u003ey\u003csub\u003ei\u003c/sub\u003e(t)\u003c/b\u003e.\u003c/p\u003e\n\n\u003ch3\u003eInput\u003c/h3\u003e\n\u003cp\u003eThe first line is an integer \u003cb\u003eT\u003c/b\u003e denotes the number of testcases. Each testcase starts with an integer \u003cb\u003en\u003c/b\u003e on a single line, the number of polynomials. The next \u003cb\u003en\u003c/b\u003e lines, each line describes a polynomial contains four integers: \u003cb\u003ea\u003csub\u003e0\u003c/sub\u003e a\u003csub\u003e1\u003c/sub\u003e a\u003csub\u003e2\u003c/sub\u003e a\u003csub\u003e3\u003c/sub\u003e\u003c/b\u003e. Then a line contains \u003cb\u003eq\u003c/b\u003e, the number of queries. Each of the next \u003cb\u003eq\u003c/b\u003e lines describes a query by a single integer \u003cb\u003et\u003c/b\u003e.\u003c/p\u003e\n\n\u003ch3\u003eOutput\u003c/h3\u003e\n\u003cp\u003eEach query, output the answer on a single line.\u003c/p\u003e\n\n\u003ch3\u003eConstraints\u003c/h3\u003e\n\u003cul\u003e\n\u003cli\u003e\u003cb\u003e1 ≤ T ≤ 10\u003c/b\u003e\u003c/li\u003e\n\u003cli\u003e\u003cb\u003e1 ≤ n, q ≤ 10\u003csup\u003e5\u003c/sup\u003e\u003c/b\u003e\u003c/li\u003e\n\u003cli\u003e\u003cb\u003e0 ≤ t ≤ 10\u003csup\u003e5\u003c/sup\u003e\u003c/b\u003e\u003c/li\u003e\n\u003cli\u003e\u003cb\u003e0 ≤ a\u003csub\u003e3\u003c/sub\u003e ≤ 10\u003csup\u003e3\u003c/sup\u003e\u003c/b\u003e\u003c/li\u003e\n\u003cli\u003e\u003cb\u003e0 ≤ a\u003csub\u003ei\u003c/sub\u003e ≤ 10\u003csup\u003e5\u003c/sup\u003e\u003c/b\u003e\u003c/li\u003e\n\u003cli\u003esum of \u003cb\u003en, q\u003c/b\u003e over all test cases, each is at most \u003cb\u003e3.10\u003csup\u003e5\u003c/sup\u003e\u003c/b\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003ch3\u003eSubtasks:\u003c/h3\u003e\n\u003cul\u003e\n\u003cli\u003eSubtask #1 (10 points): \u003cb\u003en, q ≤ 10\u003csup\u003e3\u003c/sup\u003e\u003c/b\u003e\u003c/li\u003e\n\u003cli\u003eSubtask #2 (20 points): \u003cb\u003ea\u003csub\u003e2\u003c/sub\u003e \u003d a\u003csub\u003e3\u003c/sub\u003e \u003d\n 0\u003c/b\u003e\u003c/li\u003e\n\u003cli\u003eSubtask #3 (70 points): original constrains\u003c/li\u003e\n\u003c/ul\u003e"}},{"title":"Sample 1","value":{"format":"MD","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\n5\n10 5 4 8\n2 0 5 0\n1 8 0 2\n8 7 8 7\n7 0 8 1\n4\n1\n3\n5\n2\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e7\n47\n127\n22\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}