CF1520B.Ordinary Numbers

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Ordinary Numbers

Let's call a positive integer nn ordinary if in the decimal notation all its digits are the same. For example, 11, 22 and 9999 are ordinary numbers, but 719719 and 20212021 are not ordinary numbers.

For a given number nn, find the number of ordinary numbers among the numbers from 11 to nn.

Input

The first line contains one integer tt (1t1041 \le t \le 10^4). Then tt test cases follow.

Each test case is characterized by one integer nn (1n1091 \le n \le 10^9).

Output

For each test case output the number of ordinary numbers among numbers from 11 to nn.

Samples

6
1
2
3
4
5
100
1
2
3
4
5
18

在线编程 IDE

建议全屏模式获得最佳体验