#B3721. Stone Game Challenge

    ID: 11380 Type: Default 1000ms 256MiB

Stone Game Challenge

Stone Game Challenge

Farmer John and Bessie are playing a stone game. Initially, Farmer John has \(x\) stones and Bessie has \(y\) stones. There is an infinite pile of stones available.

The game is played in turns, starting with Farmer John. In each turn, let \(w\) be the number of stones the current player has at the beginning of the move. If the current player's stone count is less than the opponent's, they take one stone from the infinite pile, increasing their count by 1. Otherwise, they must throw stones into the pile until their stone count is reduced to \(\lfloor \frac{w}{2} \rfloor\). The game ends immediately when, after a move, one of the players ends up with 0 stones.

Your task is to simulate the game and output the final number of stones held by Farmer John and Bessie.

inputFormat

The input consists of a single line containing two space-separated integers \(x\) and \(y\), representing the initial number of stones for Farmer John and Bessie respectively.

outputFormat

Output two integers separated by a space, which represent the final number of stones held by Farmer John and Bessie when the game ends.

sample

2 3
1 0