{"problem":{"name":"D. The Three Kings of Asgard","description":{"content":"The Three Kingdoms of Asgard are ruled by three very powerful and wealthy kings: Adam, Bob and Carl. Many people think they are very, very evil kings. Every year they exchange some artillery forces to","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":65536},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10094D"},"statements":[{"statement_type":"Markdown","content":"The Three Kingdoms of Asgard are ruled by three very powerful and wealthy kings: Adam, Bob and Carl. Many people think they are very, very evil kings. Every year they exchange some artillery forces to keep the kingdom at peace.\n\nTraditionally king Adam has to give to king Bob as much force as king Bob has. then King Bob gives King Carl as much force as King Carl has. In the end King Carl gives King Adam as much force as King Adam has left.\n\nThis year the three kings were surprised to find that all three of them have the same amount of force, but they couldn't recall how this happened so it's your job to find out how much force each one had last year!\n\nThe first line contains T the number of test cases your program has to solve.\n\nEach test case contains one number N(1 ≤ N ≤ 109) the amount of force each king has this year.\n\nFor each testcase output three integers: A, B, C. The amount of power Adam, Bob and Carl had last year, respectively. Or say that it is _\"Impossible\"_.\n\nIn the first testcase:\n\nlast year: Adam has 33, Bob has 21 and Carl has 18.\n\nAdam gives Bob as much as Bob has, so Adam in now 12 and Bob is now 42, Carl still have 18.\n\nAfter that: Bob gives Carl 18, so Adam(12), Bob(24), Carl(36)\n\nNow Carl gives Adam 12: Adam(24), Bob(24), Carl(24). So In the end Each king has 24 force, as the input indicates.\n\n## Input\n\nThe first line contains T the number of test cases your program has to solve.Each test case contains one number N(1 ≤ N ≤ 109) the amount of force each king has this year.\n\n## Output\n\nFor each testcase output three integers: A, B, C. The amount of power Adam, Bob and Carl had last year, respectively. Or say that it is _\"Impossible\"_.\n\n[samples]\n\n## Note\n\nIn the first testcase:last year: Adam has 33, Bob has 21 and Carl has 18.Adam gives Bob as much as Bob has, so Adam in now 12 and Bob is now 42, Carl still have 18.After that: Bob gives Carl 18, so Adam(12), Bob(24), Carl(36)Now Carl gives Adam 12: Adam(24), Bob(24), Carl(24). So In the end Each king has 24 force, as the input indicates.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ t \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case, let $ N \\in \\mathbb{Z} $ denote the final amount of force each king has after the exchange.  \nLet $ A, B, C \\in \\mathbb{Z} $ be the initial forces of Adam, Bob, and Carl respectively before any exchange.\n\n**Constraints**  \n1. $ 1 \\le t \\le 1000 $  \n2. $ 1 \\le N \\le 10^9 $\n\n**Process**  \nThe exchange proceeds in three steps:  \n1. Adam gives Bob as much as Bob has:  \n   $ A_1 = A - B $, $ B_1 = 2B $, $ C_1 = C $  \n2. Bob gives Carl as much as Carl has:  \n   $ A_2 = A_1 $, $ B_2 = B_1 - C_1 $, $ C_2 = 2C_1 $  \n3. Carl gives Adam as much as Adam has:  \n   $ A_3 = 2A_2 $, $ B_3 = B_2 $, $ C_3 = C_2 - A_2 $\n\nFinal state: $ A_3 = B_3 = C_3 = N $\n\n**Objective**  \nSolve for $ A, B, C $ such that:  \n$$\n\\begin{cases}\n2(A - B) = N \\\\\n2B - C = N \\\\\n2C - (A - B) = N\n\\end{cases}\n$$  \nIf integer solution $ (A, B, C) $ exists and $ A, B, C > 0 $, output $ A, B, C $. Otherwise, output \"Impossible\".","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10094D","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}