Zeros and Ones - 2

No attempts yetTime limit1sMemory limit256 MB

Problem

Gusagwa, a prince of Poland, likes every number that satisfies all of the following.

  • It consists only of the digits 0 and 1.
  • It contains at least one 1.
  • It does not start with 0.

For example, 101101 is a number Gusagwa likes.

Given a natural number NN, write a program that finds the smallest number that is a multiple of NN and is also a number Gusagwa likes.

Input

The first line contains the number of test cases TT. (T10T \le 10)

Each of the next TT lines contains one natural number NN. NN is at most 1,000,000.

Output

For each test case, print on its own line the smallest number that is a multiple of NN and is a number Gusagwa likes. If no such number exists, print BRAK.