Official algorithmic problem description and constraints.
You are given three non-negative integers π₯
, π¦
and π§
. Determine whether there exist three non-negative integers π
, π
and π
satisfying the following three conditions:
where &
denotes the bitwise AND operation.
Input
Each test contains multiple test cases. The first line contains the number of test cases π‘
(1β€π‘β€10
4
). The description of the test cases follows.
The first and only line of each test case contains three integers π₯
, π¦
and π§
(0β€π₯,π¦,π§β€10
9
) β the target values of π&π
, π&π
and π&π
, respectively.
Output
For each test case, output "YES" if there exists three non-negative integers π
, π
, and π
satisfying the above conditions, and "NO" otherwise.
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
Example
Input
Copy
5 1 1 1 3 2 6 4 8 12 9 10 12 12730 3088 28130
Output
Copy
YES YES NO YES NO
Note
In the first test case, π=3
, π=5
, and π=9
satisfies the condition as 3&5=1
, 5&9=1
, and 3&9=1
.
In the second test case, π=7
, π=3
, and π=22
satisfies the condition as 7&3=3
, 3&22=2
, and 7&22=6
.
In the third test case, it can be proven that there are no three non-negative integers π
, π
, and π
such that π&π=4
, π&π=8
, and π&π=12
.
Detailed video explanations, mathematical intuition, and clean C++ implementation code.