#P3388. Coprime

    ID: 2272 远端评测题 2000ms 32MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>The 5th Guangting Cup Central China Invitational Programming Contest

Coprime

Problem Description

Please write a program to calculate the k-th positive integer that is coprime with m and n simultaneously. A is coprime with B when their greatest common divisor is 1.

Input

The first line contains one integer T representing the number of test cases.
For each case, there's one line containing three integers m, n and k (0 < m, n, k <= 10^9).

Output

For each test case, in one line print the case number and the k-th positive integer that is coprime with m and n.
Please follow the format of the sample output.

3 6 9 1 6 9 2 6 9 3
Case 1: 1 Case 2: 5 Case 3: 7

Author

xay@whu