Tetration
View as PDFLittle Gilly has been struggling in Maths recently. He's supposed to be learning about exponentiation. His teacher, has asked him
"Please multiply
by itself
times"
But something is very wrong with Gilly's hearing, and he heard:
"Please raise
to the power of itself
times"
Unbeknownst to him, he has just discovered tetration, a fast-growing operation defined as repeated exponentiation.
For integers and
, the answer Gilly gets is
"the tetration of a to b":
The above notation is known as Knuth's up-arrow notation.
Gilly has been set questions, and has written down answers to all of the questions.
You may assume, surprisingly, that Gilly answered all the questions correctly according to his interpretation of the question, meaning he has accurately calculated .
However, Gilly's handwriting is illegible, and would like to know what numbers he has written down. Since this number may be huge, output the answer
. The answer will fit in a
-bit signed integer.
Input Specification
The first line of input contains a single integer, , the number of questions Gilly has answered. (
)
The next lines each consist of three space-separated integers
,
, and
, for
.
Output Specification
Output lines. The
-th line should contain a single integer, Gilly's calculation of
.
Constraints
Subtask 1
Subtask 2
No other constraints.
Sample Input 1
2
3 2 100
2 4 1000
Sample Output 1
27
536
Explanation
Notes
Tetration is a right-associative operation, meaning the repeated exponentiation is evaluated from top to bottom, e.g.
Comments