Pendu can't run

4

1 votes
Hard, Number Theory
Problem

Pendu wanted to play cricket. But, as he is fat, he can't run. He asked his friend Mahi to be his runner. Mahi agreed to help him if he can find the answer to his question.

He gave Pendu three integers N, a, b and asked him to calculate f(N,a) modulo (ab), where 

                            f(X,y)=X!y(max power of y in X!)

As Pendu is also very weak in maths, he needs assistance. Help him to find the answer so that he can play cricket.

 

INPUT FORMAT

The first line of the input contains a single integer T denoting the number of test cases.
Each test case contains three space-separated integers N, a, b

 

OUTPUT FORMAT

Output a single integer denoting the required answer.


INPUT CONSTRAINTS

1T1000N1018a is a prime number1ab105

Time Limit: 2
Memory Limit: 256
Source Limit:
Editor Image

?