eolymp
bolt
Try our new interface for solving problems
Problems

The Billiards

The Billiards

Billiards is a rectangle with the sizes of MxN, where M and N is natural numbers. From an overhead left pocket a bullet takes off under the corner of 45° to the nearby sides. The pockets are placed only in the corners of billiards. You have to define the quantity of collisions of bullet with the sides of billiards, after which it again will get in one of the pockets, and the number of pocket in which will get in bullet. You have to consider that friction absents, a collision is absolutely resilient, and bullet is a material point.

prb58

Input

In the front row, two numbers M and N, 1 ≤ M, N ≤ 2000000000. Numbering Luz clockwise from top left pocket, from which viletel ball, according to the picture. M - horizontal side of the billiard, N - the vertical side of the billiard.

Output

Two numbers through gap: the number of reflections of the ball and the number of pockets in which the ball drops.

Time limit 1 second
Memory limit 64 MiB
Input example #1
2 1
Output example #1
1 2