{"problem":{"name":"Make N","description":{"content":"We have an integer $P=0$. Find the minimum total cost to make $P=N$ by doing the following three kinds of operations any number of times in any order. *   Increase $P$ by $1$, at a cost of $X$. *   I","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc139_b"},"statements":[{"statement_type":"Markdown","content":"We have an integer $P=0$. Find the minimum total cost to make $P=N$ by doing the following three kinds of operations any number of times in any order.\n\n*   Increase $P$ by $1$, at a cost of $X$.\n*   Increase $P$ by $A$, at a cost of $Y$.\n*   Increase $P$ by $B$, at a cost of $Z$.\n\nSolve each of the $T$ test cases given to you.\n\n## Constraints\n\n*   $1 \\le T \\le 100$\n*   $1 \\le N,A,B,X,Y,Z \\le 10^9$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$T$\n$\\mathrm{case}_1$\n$\\mathrm{case}_2$\n$\\vdots$\n$\\mathrm{case}_T$\n\nEach test case is in the following format:\n\n$N\\ A\\ B\\ X\\ Y\\ Z$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc139_b","tags":[],"sample_group":[["5\n10 3 5 2 3 6\n10 3 5 1 1000000000 1000000000\n139 2 139 1 1 1\n139 1 1 1 1 1\n139 7 10 3845 26982 30923","11\n10\n1\n139\n436604\n\nIn the first test case, below is one way to make $P=10$ at the cost of $11$, which is optimal.\n\n*   Increase $P$ by $3$, making $P=3$, at a cost of $3$.\n*   Increase $P$ by $1$, making $P=4$, at a cost of $2$.\n*   Increase $P$ by $3$, making $P=7$, at a cost of $3$.\n*   Increase $P$ by $3$, making $P=10$, at a cost of $3$."]],"created_at":"2026-03-03 11:01:13"}}