P17766 「LDOI R2」位运算 / Bit

Background

One day, @[chenbs](https://www.luogu.com.cn/user/766573) wrote the following C++ code involving bitwise operations: ```cpp (11l

Description

Given four integers $n,x,y,z$, you have to construct an array of $n$ integers $a_i\ (1\le i\le n)$, such that $\mathop{\operatorname{and}}\limits_{i=1}^n a_i=x,\mathop{\operatorname{or}}\limits_{i=1}^n a_i=y,\mathop{\operatorname{xor}}\limits_{i=1}^n a_i=z$ and $\prod\limits_{i=1}^na_i$ is maximized. In the above description, $\operatorname{and},\operatorname{or},\operatorname{xor}$ represent AND, OR, XOR in bitwise operations. If such an array $a_i$ exists, output $\max\prod\limits_{i=1}^n a_i$ modulo $998244\red{8}53$; otherwise output $-1$.

Input Format

**There are multiple test cases for this problem.** The first line contains an integer $T$, representing the number of test cases. The next $T$ lines each contain four non-negative integers $n,x,y,z$.

Output Format

For each test case: - If no solution exists, output $-1$. - Otherwise, output one integer: $\max\prod\limits_{i=1}^na_i$ modulo $998244\red{8}53$.

Explanation/Hint

### Explanation For the first test case in the first sample, choose the numbers $3,3,6$. Since $3\operatorname{and}3\operatorname{and}6=2$, $3\operatorname{or}3\operatorname{or}6=7$, $3\operatorname{xor}3\operatorname{xor}6=6$, the conditions are satisfied, and it can be shown that the product $54$ is maximal. For the second test case in the first sample, there is no sequence $a$ that satisfies the conditions. ### Constraints | Test Case | $n \le$ | $x,y,z