Every number whose unit’s digit is 3 has a repunit as its multiple. A repunit is a number which has only ones. It is of the form (10n – 1)/9. Example: 3 divides 111, 13 divides 111111.
A positive integer N will be given whose unit’s digit is 3. The task is to find the number of 1s in the smallest repunit which is divisible by the given number N.
The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consists of a single line containing a positive integer N whose unit’s digit is 3.
Corresponding to each test case, in a new line, print the number of 1s in the smallest repunit multiple of the number.
1 ≤ T ≤ 100
1 ≤ N ≤ 107
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.