题库练习 Non-coprime Split
← 上一题 下一题 →

A16232 | Non-coprime Split

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You are given two integers $l \le r$ . You need to find positive integers $a$ and $b$ such that the following conditions are simultaneously satisfied:

- $l \le a + b \le r$
- $\gcd(a, b) \neq 1$

or report that they do not exist.

$\gcd(a, b)$ denotes the [greatest common divisor](https://en.wikipedia.org/wiki/Greatest_common_divisor) of numbers $a$ and $b$ . For example, $\gcd(6, 9) = 3$ , $\gcd(8, 9) = 1$ , $\gcd(4, 2) = 2$ .

输入格式

The first line of the input contains an integer $t$ ( $1 \le t \le 500$ ) — the number of test cases.

Then the descriptions of the test cases follow.

The only line of the description of each test case contains $2$ integers $l, r$ ( $1 \le l \le r \le 10^7$ ).

输出格式

For each test case, output the integers $a, b$ that satisfy all the conditions on a separate line. If there is no answer, instead output a single number $-1$ .

If there are multiple answers, you can output any of them.

输入输出样例

输入 #1
11
11 15
1 3
18 19
41 43
777 777
8000000 10000000
2000 2023
1791791 1791791
1 4
2 3
9840769 9840769
输出 #1
6 9
-1
14 4
36 6
111 666
4000000 5000000 
2009 7
-1
2 2
-1
6274 9834495
C++ 编辑器
输入
输出