cho.sh
Notes
Loading...

Infinite Binary Tree

Time limit

1s

Memory limit

128 MB

Problem

Consider an infinite binary tree built by the following rules. Each node stores an ordered pair of two integers.

  1. The root stores (1, 1).
  2. If a node stores (a, b), its left child stores (a+b, b), and its right child stores (a, a+b).

Given a node, we want to find a shortest path from the root to that node. The path itself may be very long, so only the number of moves to a left child and the number of moves to a right child are required.

Given two integers A and B, write a program that computes how many times the shortest path from the root to the node storing (A, B) moves to a left child and to a right child.

Input

The first line contains two integers A and B. (1 ≤ A, B ≤ 2,000,000,000)

No invalid input is given.

Output

Print two integers L and R on the first line. L is the number of moves to a left child, and R is the number of moves to a right child.