You have really messed things up this time. "Go buy some square tiles," your supervisor told you. But as usual, you were either reading a message, replying to an email, or updating your Discord status. "Go buy some tiles" was all you could remember. Now your supervisor is complaining that the tiles you bought are not squares, and you'll be fired if you don't fix it! "How am I supposed to fix this?" you ask yourself. "I'm a programmer! The only tiles I know are from the game Tetris!"

You cannot afford to be fired. This is your third job in less than a month. "I have to fix it!" you repeat to yourself. You call the store where you bought the tiles, but they won't accept returns or even exchanges. "We cannot cancel orders after the merchandise has left the store," they tell you. You look at the tiles again; they are all rectangular and of the same size. If you try to cut them, you'll lose too much, even if you could cut them into perfect squares. "Wait!" you say to yourself. You take several tiles and arrange them into a square. But that won't convince your boss—the tiles are small, but the square you made is too large. You look at the square again and get another idea. "I'm on a roll today!" you say proudly to yourself. You have figured out how to form the smallest possible square using the least number of tiles.

You immediately bring your supervisor to show your discovery. He is not much impressed. Explaining the algorithm, you are flustered and hardly able to make sense. You realize that the calculation is much simpler than what you managed to say, but you just couldn't think straight. Finally, your supervisor shouts: "First, the tiles must be laid in the same orientation. Second, this is a construction office, not a software shop! How are workers supposed to figure out this number? Write a program to perform this calculation right now, or pack your netbook, camera, iPod, blackberry, and get out of here this minute!"
The input consists of multiple test cases. Each line represents one test and contains two positive integers and (0 < W, H < 10^6)—the width and height of each tile. The last line contains two zeros and is not processed.
For each test case, output the result on a separate line.
Example 1