Lũy thừa mod

View as PDF




Time limit:
Python 0.75s

Problem type
Points: 250 (p) Time limit: 2.0s Memory limit: 640M Input: stdin Output: stdout

Tính: \(a^{b^c}\) \(mod\) \(10^{18} + 9\).

Input

  • Dòng đầu ghi \(Q\) không quá \(5000\) - số câu hỏi.
  • \(Q\) dòng tiếp theo mỗi dòng ghi 3 số \(a,b,c\) không quá \(10^{15}\).

Output

  • Ứng với mỗi testcase, in ra đáp án cần tìm.

Example

Test 1

Input
3
2 3 2
5 2 2
3 4 5
Output
512
625
824168097938645257

Comments

There are no comments at the moment.