#GCD3. Discrete Math Problem
Discrete Math Problem
Given N, M and K (1 ≤ N, M ≤ 100200 and 1 ≤ K ≤ 16) which
N = a + b
M = a2 + b2 - (2K - 2) × a × b
with a > 0, b > 0 and gcd(a, b) = 1.
Your task is to find gcd(N, M).
Input
The input file consists of several data sets. The first line contains the number of data sets T (1 ≤ T ≤ 10000). The following T lines describe the data sets, one triple (N, M, K) for each.
Output
For each data test in the input write the gcd(N, M).
Example
Input: 2
648570884104668119354133 420644191708310845403065233058235585438328857465 5
8017723549 59173349743176010825 9
Output: 1
1
Note: For the first trio a = 648570884104668119354126 and b = 7.
For the second a = 8016478423 and b = 1245126.