#P15318. [VKOSHP 2025] System of Equations with XOR
[VKOSHP 2025] System of Equations with XOR
Description
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 ) = () = = .
Input Format
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.
Output Format
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.
2
21 4
9 0
7 3
3 3
Hint
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.
京公网安备 11011102002149号