{"problem":{"name":"Division into Multiples","description":{"content":"Snuke has $X+Y$ balls. $X$ of them have an integer $A$ written on them, and the other $Y$ of them have an integer $B$ written on them. Snuke will divide these balls into some number of groups. Here, e","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc045_f"},"statements":[{"statement_type":"Markdown","content":"Snuke has $X+Y$ balls. $X$ of them have an integer $A$ written on them, and the other $Y$ of them have an integer $B$ written on them.\nSnuke will divide these balls into some number of groups. Here, every ball should be contained in exactly one group, and every group should contain one or more balls.\nA group is said to be **good** when the sum of the integers written on the balls in that group is a multiple of an integer $C$. Find the maximum possible number of good groups.\nSolve $T$ test cases for each input file.\n\n## Constraints\n\n*   $1 \\leq T \\leq 2 \\times 10^4$\n*   $1 \\leq A,X,B,Y,C \\leq 10^9$\n*   $A \\neq B$\n\n## Input\n\nInput is given from Standard Input in the following format. The first line is as follows:\n\n$T$\n\nThen, $T$ test cases follow. Each test case is given in the following format:\n\n$A$ $X$ $B$ $Y$ $C$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc045_f","tags":[],"sample_group":[["3\n3 3 4 4 5\n2 1 1 5 3\n3 1 4 2 5","2\n2\n0\n\nIn the first test case, we can have two good groups by making the following groups: ${3,3,4}$ and ${3,4,4,4}$.\nIn the second test case, we can have two good groups by making the following groups: ${2,1}, {1,1,1},$ and ${1}$."]],"created_at":"2026-03-03 11:01:13"}}