エクサウィザーズプログラミングコンテスト2021(AtCoder Beginner Contest 222)
G
222
AtCoder
⌀ 2242
原题
←H →
翻译中…

Problem Statement

翻译中…

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

翻译中…

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

翻译中…

Given $T$ cases, solve each of them.

翻译中…

Constraints

翻译中…
  • $1 \leq T \leq 200$
  • $1 \leq K \leq 10^8$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T

翻译中…

Each case is in the following format:

翻译中…

K

翻译中…

Output

翻译中…

Print $T$ lines. The $i$-th line should contain the answer for $\text{case}_i$.

翻译中…

样例

Input #1
4
1
7
10
999983
Output #1
1
6
-1
999982
We have four cases. - $2$ is a multiple of $1$. - None of $2,22,222,2222,22222$ is a multiple of $7$, but $222222$ is. - None of $2,22,\ldots$ is a multiple of $10$.
题目信息

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。