CF2153B Bitwise Reversion

Description

You are given three non-negative integers $ x $ , $ y $ and $ z $ . Determine whether there exist three non-negative integers $ a $ , $ b $ and $ c $ satisfying the following three conditions: - $ a \mathbin{\&} b = x $ - $ b \mathbin{\&} c = y $ - $ a \mathbin{\&} c = z $ where $ \mathbin{\&} $ denotes the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND).

Input Format

Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 10^4 $ ). The description of the test cases follows. The first and only line of each test case contains three integers $ x $ , $ y $ and $ z $ ( $ 0\le x, y, z\le 10^9 $ ) — the target values of $ a \mathbin{\&} b $ , $ b \mathbin{\&} c $ and $ a \mathbin{\&} c $ , respectively.

Output Format

For each test case, output "YES" if there exists three non-negative integers $ a $ , $ b $ , and $ c $ 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.

Explanation/Hint

In the first test case, $ a = 3 $ , $ b = 5 $ , and $ c = 9 $ satisfies the condition as $ 3 \mathbin{\&} 5 = 1 $ , $ 5 \mathbin{\&} 9 = 1 $ , and $ 3 \mathbin{\&} 9 = 1 $ . In the second test case, $ a = 7 $ , $ b = 3 $ , and $ c = 22 $ satisfies the condition as $ 7 \mathbin{\&} 3 = 3 $ , $ 3 \mathbin{\&} 22 = 2 $ , and $ 7 \mathbin{\&} 22 = 6 $ . In the third test case, it can be proven that there are no three non-negative integers $ a $ , $ b $ , and $ c $ such that $ a \mathbin{\&} b = 4 $ , $ b \mathbin{\&} c = 8 $ , and $ a \mathbin{\&} c = 12 $ .