This page is still under construction.

Parts of this page are still being built. What you see may change.

Product of Distinct Integers

Time limit1sMemory limit128 MB

Summary
Decide whether n can be expressed as a product of k distinct positive integers.
Level

Medium7 of 10

Topics
Number theory, Greedy, Math
Solved
No attempts yet

Problem

Given a positive integer nn, determine whether it can be written as a product of kk distinct positive integers.

In other words, decide whether there exist positive integers a1,a2,…,aka_1, a_2, \ldots, a_k, all different from one another, such that n=a1×a2×⋯×akn = a_1 \times a_2 \times \cdots \times a_k.

Input

The first line contains a single integer tt (1≤t≤40001 \le t \le 4000), the number of test cases.

Each of the next tt lines contains two integers nn and kk (1≤n≤1091 \le n \le 10^9, 1≤k≤201 \le k \le 20), separated by a space.

Output

Print exactly tt lines. On the ii-th line print TAK if the ii-th value nn can be represented as a product of kk distinct positive integers, or NIE otherwise.

Examples4

  1. Example 1

    Input
    3
    15 2
    24 4
    24 5
    
    Expected output
    TAK
    TAK
    NIE
    
  2. Example 2

    Input
    4
    1 1
    7 1
    1000000000 1
    999999999 1
    
    Expected output
    TAK
    TAK
    TAK
    TAK
    
  3. Example 3

    Input
    5
    1 1
    1 2
    1 3
    1 20
    1 5
    
    Expected output
    TAK
    NIE
    NIE
    NIE
    NIE
    
  4. Example 4

    Input
    6
    4 3
    8 3
    8 4
    12 3
    16 3
    16 4
    
    Expected output
    NIE
    TAK
    NIE
    TAK
    TAK
    NIE