QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 512 MB 満点: 100 ハック可能 ✓

#9589. Dragon Study

統計

Smolder, also known as Smolder the Dragon, is a hero character from the popular competitive game League of Legends. Known for his late-game scaling and cute appearance, he is active in both official tournaments and fan works. In the game, Smolder needs to rely on his passive ability to find opportunities to stack "Dragon Practice" layers, thereby increasing his attack power.

Recently, Smolder traveled through a dimensional rift and arrived in the real world, deciding to start his own stacking plan. Initially, Smolder has 0 "Dragon Practice" layers. Starting from the year 2024, he will gain 1 "Dragon Practice" layer through training every year; as for leap years, he just wants to rest and play, so his "Dragon Practice" layer count remains unchanged.

However, do not use the mortal scale of years to distinguish between common years and leap years! As an emperor dragon, Smolder's lifespan is billions of times that of a human, so the rules for leap years must be adjusted: based on the "leap every four years, skip every hundred years, leap every four hundred years" rule, add the restriction of "skip every ten thousand years," and then "leap every forty thousand years, skip every million years...". Formally, a year $n$ is a leap year if and only if there exists a unique non-negative integer $p$ such that $n$ is divisible by $4 \times 100^p$ but not divisible by $100^{p+1}$; otherwise, the year $n$ is a common year.

The question is, in which year will Smolder stack his $k$-th "Dragon Practice" layer? Please output the corresponding year, otherwise Smolder will come to you to collect his "Dragon Practice" layers.

Input

The first line contains the number of test cases $T$ ($1 \le T \le 10^5$).

For each test case, read one integer $k$ ($1 \le k \le 10^{18}$) in a single line, representing the number of "Dragon Practice" layers.

Output

For each test case, output one integer in a single line, which is the year he stacks his $k$-th "Dragon Practice" layer.

Examples

Input 1

5
2
3
4
114514
998244353

Output 1

2026
2027
2029
153181
1317684570

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.