Monk and Divisible Numbers
Tag(s):

## Easy-Medium, Modular exponentiation, Prime Factorization, approved

Problem
Editorial
Analytics

Given 3 numbers A, B and C, Monk wants you to tell him the smallest positive integer K, such that $A \times K$ is evenly divisible by $B^C$. In short, you need to tell Monk the smallest K, such that $K>0$, and $(A \times K) \% (B^C)=0$.

You shall be given multiple test cases in a single input file. For each test case, print the answer on a new line. As the answer could be rather large, print it Modulo $10^9+7$.

Input Format :

The first line contains a single integer T, denoting the number of test-cases in a single line. Each of the next T lines contains 3 space separated integers, i.e. A, B and C.

Output Format :

For each test case, print the required answer on a new line. As the answer could be rather large, print it Modulo $10^9+7$.

Constraints :

$1 \le T \le 10$

$1 \le A, B ,C \le 10^{12}$

SAMPLE INPUT
2
2 5 2
1029 3861 7652
SAMPLE OUTPUT
25
141813286
Explanation

For the 1st test in the sample, $5^2$=$25$. The smallest K, such that $A \times K$ is divisible by $25$, is $25$.
As $2 \times 25$ = $50$, that is divisible by $25$.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in

Challenge Name

CodeMonk (Number Theory Part I)

OTHER PROBLEMS OF THIS CHALLENGE
• Math > Number Theory
• Math > Number Theory
• Math > Number Theory
• Math > Number Theory