We are interested in the divisors of a given natural number n. Let D(n) denote the set of all divisors of n. We are given an expression built from constants taken from D(n), variables that may take any value in D(n), and two binary functions that compute the greatest common divisor and the least common multiple.
For a given expression, decide whether its value is the same for every possible assignment of values to the variables, that is, whether the expression denotes a constant function.
The first line contains an integer t (1≤t≤1000), the number of test cases. Each of the next t lines describes one test case.
Each description starts with an integer n (1≤n≤1018), followed by the description of the expression. An expression is a constant, a variable, or a function application.
NWD and NWW denote the functions computing the greatest common divisor and the least common multiple, respectively. A function name is followed by a single space and then the space-separated descriptions of its two arguments, each of which is itself an expression (so the description is recursive).The total size of the input does not exceed 2 MB.
Print t lines, one answer per test case. For each test case print TAK (Polish for yes) if the expression denotes a constant function regardless of the variable values, and NIE (Polish for no) otherwise.