2786. How many digits

Easy循环基本算法

时间限制:2000 ms

内存限制:256 MiB

题面

Given any integer 0 < = n < = 10000 not divisible by 2 or 5, some multiple of n is a number which in decimal notation is a sequence of 1's. How many digits are in the smallest such a multiple of n?

输入格式

the first line of input gives the number of cases, T(1 < = T < = 50) T cases follow.

Each case contains an integer n.

输出格式

Output one line,with the answer described above;

样例

输入

3
3
7
9901

输出

3
6
12