Given an undirected graph with $n$ vertices, initially the graph has no edges. Maintain $q$ operations of the following two types:
- $+\ u\ v\ w$: Add an edge connecting vertices $u$ and $v$, with a weight of $w$.
- $?\ u\ v$: Define the weight of a path to be the bitwise-and of the weights of all edges in the path. Calculate the largest possible weight of a path starting from vertex $u$ and ending at vertex $v$. If there is no path connecting vertices $u$ and $v$, the answer should be $-1$.
Input
There are multiple test cases. The first line of the input contains an integer $T$ ($1 \le T \le 100$) indicating the number of test cases. For each test case:
The first line contains two integers $n$ and $q$ ($2 \le n \le 10^3$, $1 \le q \le 10^6$) indicating the number of vertices and the number of operations.
For the following $q$ lines, the $i$-th line first contains a character $op$ ($op \in \{+, ?\}$) indicating the type of the $i$-th query.
- If $op = +$, then three integers $u$, $v$ and $w$ follow ($1 \le u, v \le n$, $0 \le w < 2^{12}$), indicating an operation of the first type.
- If $op = ?$, then two integers $u$ and $v$ follow ($1 \le u, v \le n$, $u \ne v$), indicating an operation of the second type.
It's guaranteed that there is at least one operation of the second type for each test case. Also the sum of $n$ of all test cases does not exceed $10^3$, and the sum of $q$ of all test cases does not exceed $10^6$.
Output
To decrease the size of output, for each test case just output one line containing one integer, indicating the sum of the answers to all operations of the second type.
Examples
2
4 11
+ 1 3 6
+ 3 4 2
? 1 4
+ 1 4 3
? 4 1
+ 4 3 4
? 1 4
+ 3 2 3
? 1 2
+ 1 1 4
? 1 3
4 4
+ 1 2 64
+ 3 4 32
? 1 2
? 3 1
17
63
Note
For the first sample test case, the answers to the operations of the second type are $2$, $3$, $4$, $2$, and $6$.
For the second sample test case, the answers to the operations of the second type are $64$ and $-1$.