408181: GYM103048 B Bracelet

Memory Limit:512 MB Time Limit:5 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Bracelettime limit per test5 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

Cuber QQ has got a bracelet with countless number of pearls. Each pearl has a number written on it, and most remarkably, they are increasing integers counting from $$$1$$$. When you read the bracelet from beginning to end, it forms a large number. For example, assuming there are $$$11$$$ pearls on the bracelet, it reads "1234567891011". The market owner, however, is interested in whether a specific pattern exists in the bracelet. For example, "7891" exists in the bracelet above, but not "124", and neither "019".

Given a pattern $$$n$$$, please find the least number of pearls the bracelet needs to be equipped with before you can find the pattern on the bracelet.

Input

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

Each of the next $$$T$$$ lines contains one integer $$$n$$$ ($$$1\le n\le 10^{18}$$$). It is guaranteed that $$$n$$$ does not have a leading zero.

Output

For each test case, output one integer $$$m$$$, means the least number of pearls the bracelet needs.

ExampleInput
3
5
45
32
Output
5
5
24

加入题单

算法标签: