The Billiards#58

The Billiards

1 second
64 megabytes
Very easy
prb58

A billiard table is a rectangle of size M \times N, where and are positive integers. A ball starts from the top-left pocket and moves at a 45^\circ angle toward the adjacent sides. Pockets are located only in the corners of the table.

Determine how many times the ball will collide with the sides of the table before falling into another pocket, and the number of the pocket into which it lands. Assume there is no friction, all collisions are perfectly elastic, and the ball is a point mass.

Input

The first line contains two integers and (1 \le M, N \le 2\ 000\ 000\ 000). Pockets are numbered clockwise, starting from the top-left pocket (see figure), which is also the starting position of the ball. is the horizontal side, and is the vertical side of the table.

Output

Output two integers: the number of collisions before the ball lands in a pocket, and the number of the pocket where it lands.

Examples

Example 1

Loading
Loading