AtCoder Regular Contest 141
A
Periodic Number
AtCoder
⌀ 734
原题
←B →
翻译中…

Problem Statement

翻译中…

For a positive integer $n$, let $\mathrm{str}(n)$ be the string representing $n$ in decimal.

翻译中…

We say that a positive integer $n$ is periodic when there exists a positive integer $m$ such that $\mathrm{str}(n)$ is the concatenation of two or more copies of $\mathrm{str}(m)$. For example, $11$, $1212$, and $123123123$ are periodic.

翻译中…

You are given a positive integer $N$ at least $11$. Find the greatest periodic number at most $N$. It can be proved that there is at least one periodic number at most $N$.

翻译中…

You will get $T$ test cases to solve.

翻译中…

Constraints

翻译中…
  • $1 \leq T \leq 10^4$
  • $11 \leq N < 10^{18}$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

T
\mathrm{case}_1
\vdots
\mathrm{case}_T

翻译中…

Each case is given in the following format:

翻译中…

N

翻译中…

Output

翻译中…

Print $T$ lines. The $i$-th line should contain the answer for the $i$-th test case.

翻译中…

样例

Input #1
3
1412
23
498650499498649123
Output #1
1313
22
498650498650498650
For the first test case, the periodic numbers at most $1412$ include $11$, $222$, $1212$, $1313$, and the greatest is $1313$.
题目信息
题号
arc141_a
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。