Maximum 0ccurrences

Time limit: 0.1s Memory limit: 32MB Input: Output:

You are given an integer nn and you have to do one operation at a time:

1.1. If nn is odd, you must multiple it by 33 and add 11 to the result.

2.2. If nn is even, you must divide it by 22.

What is the number with maximum occurrences if you do 1010010^{100} operations on the given number nn?

Input data

The first line of the input will contain tt, the number of test cases.

Each of the next tt lines will contain a single number nn.

Output data

On each line of the output we will print an integer, representing the answer to the problem. If there are multiple solutions, print the biggest one of them.

Constraints and Clarifications

  • 1n10181 \leq n \leq 10^{18}
  • 1t1051 \leq t \leq 10^5
  • For tests worth 5050 points, 1n1 0001 \leq n \leq 1 \ 000.

Example 1

stdin

3
2
18
1

stdout

2
4
1

Explanation

For the first sample test case, the numbers printed will be 22, 11, 44, 22, 11, \dots, and therefore 22 and 11 will show up one more time than the other numbers. Since we need to print the biggest integer, then we will print 22.

Log in or sign up to be able to send submissions!