logo AlgoBeat OnlineJudge
登录 注册

#215456. [VKOSHP 2025] System of Equations with XOR

内存限制:512 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Alice and Bob love problems involving random numbers. One day they came up with the following problem:

  • First, Alice chooses a random integer from the range of to , all numbers are equally likely.
  • Then, Bob chooses a random integer from the range of to , all numbers are equally likely.
  • They calculate the product of these numbers and their bitwise XOR .

You are given two resulting integers and . Find any pair of natural numbers and such that:

where denotes the bitwise XOR operation.

Recall that the bitwise "exclusive or" (, xor) of two non-negative integers is defined as follows: write both numbers in binary representation; the -th binary digit of the result is 1 if exactly one of the arguments has it equal to 1. For example, ( xor ) = () = = .

输入格式

The first line of the input contains a single integer --- the number of test cases.

In the following lines of input, there are two integers and (, ) --- the description of the next test case.

输出格式

For each test case, output in a separate line two natural numbers and , separated by a space, such that and .

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

样例

样例输入 1

2
21 4
9 0

样例输出 1

7 3
3 3

数据范围与提示

In this problem, there are tests, including the example from the statement. It is guaranteed that in all tests, except for the example from the statement, , and the numbers and for each test case were generated by choosing random numbers and by Alice and Bob.