Let's consider a string which is obtained by concatenating the non-negative integers from 0 to without leading zeroes and in increasing order.
So S = "0123456789101112131415…"
.
You are given another string containing digits from 0 to 9. You need to find the length of the largest substring of which is also a substring of .
The first line will contain an integer (), the number of test cases.
Each of the next t lines will contain a string () containing digits from 0 to 9. Note that can contain leading zeroes.
Output the length of the largest substring of which is also a substring of .
Input | Output |
---|---|
2 01 9 | 2 1 |