{"raw_statement":[{"iden":"statement","content":"They were all dead. The final lunge was an exclamation mark to everything that had led to this point. I wiped my sword from the blood of Dragon and sheathed it. And then it was all over. Devastated, I came out of the empty castle and wandered somewhere along a dirt road. But before I could think about what I would do now, I heard a piercing scream from behind: \"Stop right now! Drop a sword and raise your hands up!\". They were knights. Only knights scream like that before making a hit. If they had been bandits I would be already dead.\n\nI turned back and saw two figures in heavy armor rushing towards me. They were Lancelot and Percival — two knights of the Round Table, known for their fast reprisal over renegades like me. In the Kingdom they were called the Cleaners. As for me, not the most suitable name: they usually left a lot of dirt.\n\nI almost instantly read their technique. Each of them was preparing for some time, then hit instantly, then was preparing again for the same time, then hit again, and so on, while their victim was not fallen. Lancelot spent n seconds to prepare, and Percival — m seconds. I was too tired and could parry a hit only if the previous one was done more than a second ago, and there were no powers to counter-attack at all. It was the sense that Lady Luck was really a hooker, and you were fresh out of cash. The knights knew their job and the first hit I wouldn't be able to parry would finish me off. My story wouldn't have a happy end.\n\nThe only line contains two integers separated by a space: n and m (1 ≤ n, m ≤ 2·109) — the intervals of time in seconds between hits of Lancelot and Percival correspondingly.\n\nOutput a single integer — the number of seconds from the beginning of the fight when the protagonist will be killed.\n\n"},{"iden":"input","content":"The only line contains two integers separated by a space: n and m (1 ≤ n, m ≤ 2·109) — the intervals of time in seconds between hits of Lancelot and Percival correspondingly."},{"iden":"output","content":"Output a single integer — the number of seconds from the beginning of the fight when the protagonist will be killed."},{"iden":"examples","content":"Input9 6Output18Input7 11Output22"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ t \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case $ k \\in \\{1, \\dots, t\\} $:  \n- Let $ n_k \\in \\mathbb{Z} $ denote the number of jars, with $ 2 \\leq n_k \\leq 1000 $.  \n- Let $ A_k = (a_{k,1}, a_{k,2}, \\dots, a_{k,n_k}) $ be a sequence of positive integers, where $ a_{k,i} \\in \\mathbb{Z} $ and $ 1 \\leq a_{k,i} \\leq 1000 $ represents the number of candies in jar $ i $.\n\n**Constraints**  \n1. $ 1 \\leq t \\leq \\text{unspecified} $ (implied by input format)  \n2. For each $ k \\in \\{1, \\dots, t\\} $:  \n   - $ 2 \\leq n_k \\leq 1000 $  \n   - $ 1 \\leq a_{k,i} \\leq 1000 $ for all $ i \\in \\{1, \\dots, n_k\\} $\n\n**Objective**  \nDetermine the winner of a two-player impartial game under optimal play, where on each turn a player selects one jar and removes any positive number of candies from it. The player who takes the last candy wins.  \n\nThis is equivalent to the standard **Nim game**. The winner is determined by the **Nim-sum** (XOR of all pile sizes):  \n$$\nS_k = \\bigoplus_{i=1}^{n_k} a_{k,i}\n$$  \n- If $ S_k \\neq 0 $, then **Alice** wins (first player).  \n- If $ S_k = 0 $, then **Bob** wins (second player).","simple_statement":"Alice and Bob take turns picking any number of candies from one jar. The player who takes the last candy wins. Given the number of candies in each jar, determine who wins if both play optimally.","has_page_source":false}