CF1549A.Gregor and Cryptography

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Gregor and Cryptography

Gregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers and factoring them.

Gregor's favorite prime number is PP. Gregor wants to find two bases of PP. Formally, Gregor is looking for two integers aa and bb which satisfy both of the following properties.

  • Pmoda=PmodbP \bmod a = P \bmod b, where xmodyx \bmod y denotes the remainder when xx is divided by yy, and
  • 2a<bP2 \le a \lt b \le P.

Help Gregor find two bases of his favorite prime number!

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t10001 \le t \le 1000).

Each subsequent line contains the integer PP (5P1095 \le P \le {10}^9), with PP guaranteed to be prime.

Output

Your output should consist of tt lines. Each line should consist of two integers aa and bb (2a<bP2 \le a \lt b \le P). If there are multiple possible solutions, print any.

Note

The first query is P=17P=17. a=3a=3 and b=5b=5 are valid bases in this case, because 17mod3=17mod5=217 \bmod 3 = 17 \bmod 5 = 2. There are other pairs which work as well.

In the second query, with P=5P=5, the only solution is a=2a=2 and b=4b=4.

Samples

2
17
5
3 5
2 4

在线编程 IDE

建议全屏模式获得最佳体验