{"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\"\u003eMr.Panda is about to engage in his favourite activity doing laundry! He’s brought L indistinguishable loads of laundry to his local laundromat, which has N washing machines and M dryers.The $i^{th}$ washing machine takes $W_i$ minutes to wash one load of laundry, and the $i^{th}$ dryer takes Di minutes to dry a load of laundry.\u003cbr\u003eAt any point in time, each machine may only be processing at most one load of laundry.\u003cbr\u003eAs one might expect, Panda wants to wash and then dry each of his L loads of laundry. Each load of laundry will go through the following steps in order:\u003cbr\u003e1. A non-negative amount of time after Panda arrives at the laundromat, Panda places the load in an unoccupied washing machine i.\u003cbr\u003e2. Wi minutes later, he removes the load from the washing machine, placing it in a temporary holding basket (which has unlimited space)\u003cbr\u003e3. A non-negative amount of time later, he places the load in an unoccupied dryer j \u003cbr\u003e4. Dj minutes later, he removes the load from the dryer Panda can instantaneously add laundry to or remove laundry from a machine. Help Panda minimize the amount of time (in minutes after he arrives at the laundromat) after which he can be done washing and drying all L loads of laundry!\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input gives the number of test cases, T.\u003cbr\u003eT test cases follow. Each test case consists of three lines. The first line contains three integer L, N, and M.\u003cbr\u003eThe second line contains N integers $W_1, W_2, ... , W_N$ representing the wash time of each wash machine.\u003cbr\u003eThe third line contains M integers $D_1, D_2, ..., D_M$ representing the dry time of each dryer.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output one line containing “Case #x: y”, where x is the test case number (starting from 1) and y is the minimum time it will take Panda to finish his laundry.\u003cbr\u003e\u003ch2\u003elimits\u003c/h2\u003e\u003cbr\u003e$\\bullet 1 ≤ T ≤ 100$.\u003cbr\u003e$\\bullet 1 ≤ L ≤ 10^6$.\u003cbr\u003e$\\bullet 1 ≤ N, M ≤ 10^5$.\u003cbr\u003e$\\bullet 1 ≤ W_i, D_i ≤ 10^9$."}},{"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 1\r\n1200\r\n34\r\n2 3 2\r\n100 10 1\r\n10 10\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1: 1234\r\nCase #2: 12\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}