For Argo, it is very interesting watching a circle bouncing ina rectangle.
As shown inthe figure below, the rectangle is divided into N×M grids, andthe
circle fits exactly one grid.
The bouncing rule is simple:
1. The circle always starts fromthe left upper corner and moves towards lowerright.
2. If the circle touches any edge ofthe rectangle, it will bounce.
3. If the circle reaches any corner ofthe rectangle after starting, it will stop
there.
Argo wants to know how many grids the circle will go through only once untilitfirst reaches another corner. Can you help him?
Input
The input consists of multiple test cases. (Up to105)
For each test case:
One linecontainstwo integers N and M, indicating thenumberof rows and columns
ofthe rectangle. (2 ≤ N, M ≤ 10^9)
Output
For each test case, output oneline containing oneinteger, thenumberof grids
that the circle will go through exactly once untilit stops (the starting grid andthe ending grid also count).