CF1612A.Distance

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

Distance

Let's denote the Manhattan distance between two points p1p_1 (with coordinates (x1,y1)(x_1, y_1)) and p2p_2 (with coordinates (x2,y2)(x_2, y_2)) as d(p1,p2)=x1x2+y1y2d(p_1, p_2) = |x_1 - x_2| + |y_1 - y_2|. For example, the distance between two points with coordinates (1,3)(1, 3) and (4,2)(4, 2) is 14+32=4|1 - 4| + |3 - 2| = 4.

You are given two points, AA and BB. The point AA has coordinates (0,0)(0, 0), the point BB has coordinates (x,y)(x, y).

Your goal is to find a point CC such that:

  • both coordinates of CC are non-negative integers;
  • d(A,C)=d(A,B)2d(A, C) = \dfrac{d(A, B)}{2} (without any rounding);
  • d(B,C)=d(A,B)2d(B, C) = \dfrac{d(A, B)}{2} (without any rounding).

Find any point CC that meets these constraints, or report that no such point exists.

Input

The first line contains one integer tt (1t30001 \le t \le 3000) — the number of test cases.

Each test case consists of one line containing two integers xx and yy (0x,y500 \le x, y \le 50) — the coordinates of the point BB.

Output

For each test case, print the answer on a separate line as follows:

  • if it is impossible to find a point CC meeting the constraints, print "-1 -1" (without quotes);
  • otherwise, print two non-negative integers not exceeding 10610^6 — the coordinates of point CC meeting the constraints. If there are multiple answers, print any of them. It can be shown that if any such point exists, it's possible to find a point with coordinates not exceeding 10610^6 that meets the constraints.

Note

Explanations for some of the test cases from the example:

  • In the first test case, the point BB has coordinates (49,3)(49, 3). If the point CC has coordinates (23,3)(23, 3), then the distance from AA to BB is 490+30=52|49 - 0| + |3 - 0| = 52, the distance from AA to CC is 230+30=26|23 - 0| + |3 - 0| = 26, and the distance from BB to CC is 2349+33=26|23 - 49| + |3 - 3| = 26.
  • In the second test case, the point BB has coordinates (2,50)(2, 50). If the point CC has coordinates (1,25)(1, 25), then the distance from AA to BB is 20+500=52|2 - 0| + |50 - 0| = 52, the distance from AA to CC is 10+250=26|1 - 0| + |25 - 0| = 26, and the distance from BB to CC is 12+2550=26|1 - 2| + |25 - 50| = 26.
  • In the third and the fourth test cases, it can be shown that no point with integer coordinates meets the constraints.
  • In the fifth test case, the point BB has coordinates (42,0)(42, 0). If the point CC has coordinates (21,0)(21, 0), then the distance from AA to BB is 420+00=42|42 - 0| + |0 - 0| = 42, the distance from AA to CC is 210+00=21|21 - 0| + |0 - 0| = 21, and the distance from BB to CC is 2142+00=21|21 - 42| + |0 - 0| = 21.

Samples

10
49 3
2 50
13 0
0 41
42 0
0 36
13 37
42 16
42 13
0 0
23 3
1 25
-1 -1
-1 -1
21 0
0 18
13 12
25 4
-1 -1
0 0

在线编程 IDE

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