408181: GYM103048 B Bracelet
Description
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.
InputThe 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.
OutputFor each test case, output one integer $$$m$$$, means the least number of pearls the bracelet needs.
ExampleInput3 5 45 32Output
5 5 24