#ABC222G. [ABC222G] 222

[ABC222G] 222

Score : 600600 points

Problem Statement

We have a sequence 2,22,222,2222,2,22,222,2222,\ldots, where the ii-th term is an ii-digit integer whose digits are all 22.

Where does a multiple of KK appear in this sequence for the first time? If the first multiple of KK is the xx-th term of the sequence, print xx; if there is no multiple of KK, print -1.

Given TT cases, solve each of them.

Constraints

  • 1T2001 \leq T \leq 200
  • 1K1081 \leq K \leq 10^8
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

TT

case1\text{case}_1

case2\text{case}_2

\vdots

caseT\text{case}_T

Each case is in the following format:

KK

Output

Print TT lines. The ii-th line should contain the answer for casei\text{case}_i.

4
1
7
10
999983
1
6
-1
999982

We have four cases.

  • 22 is a multiple of 11.
  • None of 2,22,222,2222,222222,22,222,2222,22222 is a multiple of 77, but 222222222222 is.
  • None of 2,22,2,22,\ldots is a multiple of 1010.