The Existence of N
Time limit5sMemory limit128 MB
Given a prime p, exponent m, and residue a, decide whether some positive n makes n^n + n^m congruent to a mod p.
- Level
Medium7 of 10
- Topics
- Number theory, Math
- Solved
- No attempts yet
Problem
You are given a prime , a positive integer , and an integer with .
Determine whether there exists a positive integer such that .
Input
The first line contains the number of test cases ().
Each of the next lines contains three integers , , and (, , , ). is always prime.
Output
For each test case, print one line. If there exists a positive integer satisfying , print TAK; otherwise print NIE.