Under construction

Still being built. Things may change

Base K

Interview

Time limit1sMemory limit128 MB

Summary
Convert each n to base k and report whether every digit from 0 to k-1 appears, formatting the output line exactly as specified.
Level

Easy3 of 10

Topics
Math, Implementation, Simulation, String
Solved
No attempts yet

Problem

We are used to the decimal positional notation for representing numbers, which uses 10 digits, from 0 to 9. However, there is nothing special about 10, and we can just as easily use any other base. For example, base-2 (binary) uses only two digits, 0 and 1, while base-16 (hexadecimal) uses 00-99 and a,b,c,d,e,fa, b, c, d, e, f (representing ten, eleven, twelve, thirteen, fourteen, and fifteen); both notations are common in computing.

More generally, a base-kk representation uses kk digits, 00 through k−1k - 1. If a number nn is written in base-kk as a3a2a1a0a_3a_2a_1a_0, then

n=(a3a2a1a0)k=a3×k3+a2×k2+a1×k1+a0×k0n = (a_3a_2a_1a_0)_k = a_3 \times k^3 + a_2 \times k^2 + a_1 \times k^1 + a_0 \times k^0

where the subscript kk denotes that the number is written in base-kk. For example,

  • 4657=4×72+6×71+5×70=24310465_7 = 4 \times 7^2 + 6 \times 7^1 + 5 \times 7^0 = 243_{10}
  • 46e16=4×162+6×161+14×160=11341046e_{16} = 4 \times 16^2 + 6 \times 16^1 + 14 \times 16^0 = 1134_{10} (here ee represents fourteen in base-16)

Given two integers nn and kk, decide whether the base-kk representation of nn contains every digit from 00 to k−1k - 1.

For example, the base-3 representation of 15 is 1203120_3 (1×32+2×31+0×30=151 \times 3^2 + 2 \times 3^1 + 0 \times 3^0 = 15), which contains all three digits 0, 1, 2. In contrast, the base-4 representation of 18 is 1024102_4 (1×42+0×41+2×40=181 \times 4^2 + 0 \times 4^1 + 2 \times 4^0 = 18), which contains only 0, 1, 2 and is missing 3, so it does not contain all digits.

The base-kk representation is the standard one, without leading zeros. Therefore the digit 0 must actually appear somewhere in the middle of the number. For instance, 123456789 in base-10 contains only 1 through 9 and no 0, so it does not contain all digits (we do not pad it as 0123456789).

Digits with value 10 or greater are written as lowercase letters: 10=a10 = a, 11=b11 = b, …\ldots, 29=t29 = t.

Input

The first line contains the number of test cases TT (T<100T < 100). Each of the next TT lines contains one test case: two integers nn and kk, in that order, separated by a space. It is guaranteed that 2≤k≤302 \le k \le 30 and 0≤n<2300 \le n < 2^{30}.

Output

For each test case, print one line. Let rr be the base-kk representation of nn. If rr contains every digit from 00 to k−1k - 1, print

Base-<k> representation of <n> is <r>; contains all digits.

Otherwise, print

Base-<k> representation of <n> is <r>; does not contain all digits.

Replace <k>, <n>, and <r> with the actual values.

Examples1

  1. Example 1

    Input
    6
    100 10
    343 7
    240 5
    1234567890 10
    1 2
    2 2
    
    Expected output
    Base-10 representation of 100 is 100; does not contain all digits.
    Base-7 representation of 343 is 1000; does not contain all digits.
    Base-5 representation of 240 is 1430; does not contain all digits.
    Base-10 representation of 1234567890 is 1234567890; contains all digits.
    Base-2 representation of 1 is 1; does not contain all digits.
    Base-2 representation of 2 is 10; contains all digits.