#P6659. [POI 2019/2020 R1] Najmniejsza wspólna wielokrotność / 最小公倍数

    ID: 7464 远端评测题 3000ms 128MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>2019二分POI(波兰)最大公约数 gcd

[POI 2019/2020 R1] Najmniejsza wspólna wielokrotność / 最小公倍数

Background

Byteasar is preparing for his math exam.

Problem Description

The teacher told him that the exam would include problems about the least common multiple lcm\rm lcm, so he found a problem to practice.

Given an integer MM, find an interval [a,b][a,b] such that MM is the least common multiple of all integers in this interval.

Since you are very strong, while Byteasar was solving this problem, he also wanted to ask you for the answer to this problem.

Because Byteasar loves asking questions, he will ask you zz queries.

Input Format

The first line contains an integer zz, the number of queries.
Then follow zz lines, each containing an integer MM for one query.

Output Format

Output zz lines, each containing two integers a,ba,b, the answer for one query.

If there are multiple solutions:

  • Output the one with the smallest aa.
  • If there are still multiple solutions, output the one with the smallest bb.

If there is no solution, output NIE.

3
12
504
17
1 4
6 9
NIE
5
5
6
7
8
9
NIE
1 3
NIE
NIE
NIE
1
1000000
NIE
1
99999990000000
9999999 10000000

Hint

Sample Explanation

For the first query in sample 11, 1212 is the least common multiple of the interval [1,4][1,4].

Another additional sample is provided in the attached files sample.in and sample.out.

Constraints

This problem uses bundled testdata.

  • Subtask 1 (18 pts): z10z \le 10, M1000M \le 1000.
  • Subtask 2 (20 pts): z100z \le 100, M109M \le 10^9.
  • Subtask 3 (20 pts): z100z \le 100, M1018M \le 10^{18}.
  • Subtask 4 (42 pts): no special limits.

For 100%100\% of the testdata, 1z1041 \le z \le 10^4, 1M10181 \le M \le 10^{18}.

Note

Translated from POI 2019 A Najmniejsza wspólna wielokrotność.

Translated by ChatGPT 5