Cards#7113

Cards

1 secondo
122,174 megabyte
Facile

The deck consists of an even number of cards, numbered consecutively from to , where is a natural number. The following steps are performed on the deck:

1. The deck is split into two equal parts. The first part contains cards from the odd positions, and the second part contains cards from the even positions:

(1, 2, \ldots , 2n) \to (1, 3, 5, \ldots , 2n - 1) + (2, 4, \ldots , 2n)

2. From each part, the card at position 1 + \lfloor an/b \rfloor is removed, where 0 \le a < b \le 1000. For instance, if a = 0 and b = 1, the first card is removed:

(1, 3, 5, \ldots , 2n - 1) \to (3, 5, 7, \ldots , 2n - 1)

(2, 4, 6, \ldots , 2n) \to (4, 6, 8, \ldots , 2n)

3. The second part is placed on top of the first:

(3, 5, 7, \ldots , 2n - 1) + (4, 6, 8, \ldots , 2n) \to (3, 5, 7, \ldots , 2n - 1, 4, 6, 8, \ldots , 2n)

These steps are repeated until only cards remain in the deck. For example, if a = 1, b = 2, and the initial number of cards is , the process is as follows:

(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) \to (1, 3, 5, 7, 9) + (2, 4, 6, 8, 10)

(1, 3, 7, 9) + (2, 4, 8, 10) \to (1, 3, 7, 9, 2, 4, 8, 10) \to (1, 7, 2, 8) + (3, 9, 4, 10)

(1, 7, 8) + (3, 9, 10) \to (1, 7, 8, 3, 9, 10) \to (1, 8, 9) + (7, 3, 10)

(1, 9) + (7, 10) \to (1, 9, 7, 10) \to (1, 7) + (9, 10) \to (1) + (9) \to (1, 9),

because 1 + \lfloor 5 \cdot 1/2 \rfloor = 3, 1 + \lfloor 4 \cdot 1/2 \rfloor = 3, 1 + \lfloor 3 \cdot 1/2 \rfloor = 2, 1 + \lfloor 2 \cdot 1/2 \rfloor = 2.

Determine the final state of the deck.

Input

The input consists of non-negative integers: , , (2 \le n \le 500000).

Output

Output the numbers of the two remaining cards, with the number of the bottom card listed first.

Esempi

Esempio 1

Loading
Loading