Let us define a function:
F(N, k) = (....((N!)!)!.... )! k times, where N! = 1 * 2 * 3 * .... * (N-1) * N
For eg., F(N, 2) = (N!)! and F(N, 3) = (((N)!)!)!
Given any N and k, you have to find the value of F(N, k). Since this value can be really large, print
this value modulo 107.
First Line consists of T, the number of test cases. After this, T lines follow, each line consists of 2
space separated integers N followed by k.
For every test case, print the value of F(N, k) % 107 on a new line.
1 <= T <= 100
1 <= N <= 10,00,000
2 <= k <= 100
Test Case 1: (((1!)!)!)! = 1, 1 % 107 = 1
Test Case 2: ((((2!)!)!)!)! = 2, 2 % 107 = 2
Test Case 3: (3!)! = 6! = 720, 720 % 107 = 78