传统题 1000ms 256MiB

Grahc Plays Gokémon Po

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

Grahc is playing a game called "Gokémon Po" and he has caught a lot of "Gokémon". Every type of Pokémon has a unique positive integer as its ID. Grahc found that there exists a special item that can transform one type of Gokémon into another type of a strictly larger ID, with the result only depending on its original ID. In other words, there exists a function ff, if the original ID of the Gokémon is xx, the ID of the Gokémon after transformation will be f(x)f(x).

After several trials, Grahc found that if he uses the item twice in a row on a Gokémon of ID xx, it will be transformed into a Gokémon of ID 3x3x, no matter what xx is.

Grahc wonders what the ID of the transformed Gokémon is if he only uses it once on a Gokémon of ID xx. He wants you to write a program to predict it. One thing to notice is that Grahc has so many Gokémon, so he may ask you for more than one ID in one case.

That is, given a monotonic incremental function f:NNf:\mathbb{N}^*\mapsto\mathbb{N}^* satisfying f(f(x))=3xf(f(x))=3x. Now find f(xi)f(x_{i}) for given xix_i.

Format

Input

The first line of each input case contains an integer T(1T10)T\,(1\leq T\leq 10) that represents how many IDs he wants you to predict.

The following TT lines contain one integer xi(1xi1018)x_i(1\leq x_i\leq 10^{18}) each, representing the ID of the ii-th Gokémon before transformation.

It is guaranteed that the sum of all xix_i does not exceed 3383^{38}.

Output

For every ID xix_i, print the ID of the ii-th Gokémon after transformation f(xi)f(x_i).

Samples

1
4
7
2
1
2
2
3

Hello ACM 2025

未参加
状态
已结束
规则
ACM/ICPC
题目
11
开始于
2025-8-14 13:00
结束于
2025-8-14 18:00
持续时间
5 小时
主持人
参赛人数
46