Need help for a number theory problems !

Правка en1, от backupkid, 2026-05-16 16:42:46

Hi everyone!

I recently came across this problem and I’m not sure how to approach it efficiently. Any hints or ideas would be appreciated!


Problem Statement

Cyclic Divisibility

Given three positive integers $$$a, b, c$$$, we need to find the smallest positive integer $$$x$$$ such that:

$$$ a \cdot x \equiv 0 \pmod b $$$
$$$ b \cdot x \equiv 0 \pmod c $$$
$$$ c \cdot x \equiv 0 \pmod a $$$

---

Input

The first line contains an integer $$$T$$$ — the number of test cases ($$$1 \le T \le 10^5$$$).

Each of the next $$$T$$$ lines contains three integers $$$a, b, c$$$ ($$$1 \le a, b, c \le 10^6$$$).


Output

For each test case, print a single integer — the minimum value of $$$x$$$ satisfying the conditions.


Example

Input

2
4 6 10
12 34 56

Output

2
4 6 10
12 34 56

Thanks for reading!
Any ideas or hints would be appreciated :)

Теги number theory, lcm, gcd

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский backupkid 2026-05-16 17:32:51 17 Tiny change: 'put\n```\n2\n4 6 10\n12 34 56\n```\nTha' -> 'put\n```\n30\n1428\n```\nTha'
en1 Английский backupkid 2026-05-16 16:42:46 953 Initial revision (published)