**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Yasya and the Mysterious Tree
time_limit_ms: 2500
memory_limit_mb: 512
Description: Yasya was walking in the forest and accidentally found a tree with $n$ vertices. A tree is a connected undirected graph with no cycles.

Next to the tree, the girl found an ancient manuscript with $m$ queries written on it. The queries can be of two types.

The first type of query is described by the integer $y$. The weight of each edge in the tree is replaced by the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of the weight of that edge and the integer $y$.

The second type is described by the vertex $v$ and the integer $x$. Yasya chooses a vertex $u$ ($1 \le u \le n$, $u \neq v$) and mentally draws a bidirectional edge of weight $x$ from $v$ to $u$ in the tree.

Then Yasya finds a simple cycle in the resulting graph and calculates the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of all the edges in it. She wants to choose a vertex $u$ such that the calculated value is maximum. This calculated value will be the answer to the query. It can be shown that such a cycle exists and is unique under the given constraints (independent of the choice of $u$). If an edge between $v$ and $u$ already existed, a simple cycle is the path $v \to u \to v$.

Note that the second type of query is performed mentally, meaning the tree does not change in any way after it.

Help Yasya answer all the queries.

Input: The first line contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

The descriptions of the test cases follow.

The first line of each test case contains two integers $n$, $m$ ($2 \le n \le 2 \cdot 10^5$, $1 \le m \le 2 \cdot 10^5$) — the number of vertices in the tree and the number of queries.

The next $n - 1$ lines of each test case contain three integers $v$, $u$, $w$ ($1 \le v, u \le n$, $1 \le w \le 10^9$) — the ends of some edge in the tree and its weight.

It is guaranteed that the given set of edges forms a tree.

The next $m$ lines of each test case describe the queries:

  * ^ $y$ ($1 \le y \le 10^9$) — parameter of the first type query;    * ? $v$ $x$ ($1 \le v \le n$, $1 \le x \le 10^9$) — parameters of the second type query.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$. The same is guaranteed for $m$.

Output: For each test case, output the answers to the queries of the second type.

Examples:
input:
2
3 7
1 2 1
3 1 8
^ 5
? 2 9
^ 1
? 1 10
^ 6
? 3 1
? 2 9
5 6
1 2 777
3 2 2812
4 1 16
5 3 1000000000
^ 4
? 3 123
? 5 1000000000
^ 1000000000
? 1 908070
? 2 1
output:
13 15 11 10
1000000127 2812 999756331 999999756

input:
3
8 4
8 6 3
6 3 4
2 5 4
7 6 2
7 1 10
4 1 4
5 1 2
^ 4
^ 7
? 7 8
? 4 10
5 6
3 1 4
2 3 9
4 3 6
5 2 10
? 5 7
^ 1
^ 8
? 4 10
? 1 9
? 3 6
4 2
2 1 4
4 3 5
2 3 4
^ 13
? 1 10
output:
14 13
13 8 11 11
10

Note:

Buggy Code:
# ﷽
import sys
import heapq
from heapq import *
from math import log2,ceil,floor,gcd,sqrt,log,perm,comb,factorial
from random import randrange
from bisect import bisect_left
from collections import defaultdict, Counter, deque, OrderedDict
from functools import lru_cache, reduce
from bisect import bisect_left, bisect_right
from types import GeneratorType

input = lambda: sys.stdin.buffer.readline().decode().rstrip()

class Node:
    def __init__(self, data):
        self.data = data
        self.r1 = None
        self.l1 = None
        self.r0 = None
        self.l0 = None
        self.r1_count = 0  # Count for r1 path
        self.l1_count = 0  # Count for l1 path
        self.r0_count = 0  # Count for r0 path
        self.l0_count = 0  # Count for l0 path

class Trie:
    def __init__(self):
        self.root = Node(0)

    def insert(self, preXor, parity):
        pCrwal = self.root
        if parity:
            for i in range(31, -1, -1):
                x = preXor & (1 << i)
                if x:
                    if pCrwal.r1 is None:
                        pCrwal.r1 = Node(0)
                    pCrwal.r1_count += 1
                    pCrwal = pCrwal.r1
                else:
                    if pCrwal.l1 is None:
                        pCrwal.l1 = Node(0)
                    pCrwal.l1_count += 1
                    pCrwal = pCrwal.l1
        else:
            for i in range(31, -1, -1):
                x = preXor & (1 << i)
                if x:
                    if pCrwal.r0 is None:
                        pCrwal.r0 = Node(0)
                    pCrwal.r0_count += 1
                    pCrwal = pCrwal.r0
                else:
                    if pCrwal.l0 is None:
                        pCrwal.l0 = Node(0)
                    pCrwal.l0_count += 1
                    pCrwal = pCrwal.l0

        pCrwal.data = preXor

    def query(self, xor, parity):
        pCrwal = self.root
        if parity:
            for i in range(31, -1, -1):
                x = xor & (1 << i)
                if x:
                    if pCrwal.l1 is not None:
                        pCrwal = pCrwal.l1
                    elif pCrwal.r1 is not None:
                        pCrwal = pCrwal.r1
                else:
                    if pCrwal.r1 is not None:
                        pCrwal = pCrwal.r1
                    elif pCrwal.l1 is not None:
                        pCrwal = pCrwal.l1
            return xor ^ pCrwal.data
        else:
            for i in range(31, -1, -1):
                x = xor & (1 << i)
                if x:
                    if pCrwal.l0 is not None:
                        pCrwal = pCrwal.l0
                    elif pCrwal.r0 is not None:
                        pCrwal = pCrwal.r0
                else:
                    if pCrwal.r0 is not None:
                        pCrwal = pCrwal.r0
                    elif pCrwal.l0 is not None:
                        pCrwal = pCrwal.l0
            return xor ^ pCrwal.data

    def delete(self, preXor, parity):
        pCrwal = self.root
        stack = []
        if parity:
            for i in range(31, -1, -1):
                x = preXor & (1 << i)
                stack.append((pCrwal, x, parity))
                if x:
                    if pCrwal.r1 is None:
                        return  # Value not found, nothing to delete
                    pCrwal = pCrwal.r1
                else:
                    if pCrwal.l1 is None:
                        return  # Value not found, nothing to delete
                    pCrwal = pCrwal.l1
        else:
            for i in range(31, -1, -1):
                x = preXor & (1 << i)
                stack.append((pCrwal, x, parity))
                if x:
                    if pCrwal.r0 is None:
                        return  # Value not found, nothing to delete
                    pCrwal = pCrwal.r0
                else:
                    if pCrwal.l0 is None:
                        return  # Value not found, nothing to delete
                    pCrwal = pCrwal.l0

        # Decrement count and remove nodes with count 0
        while stack:
            node, x, parity = stack.pop()
            if parity:
                if x:
                    node.r1_count -= 1
                    if node.r1_count == 0:
                        node.r1 = None
                else:
                    node.l1_count -= 1
                    if node.l1_count == 0:
                        node.l1 = None
            else:
                if x:
                    node.r0_count -= 1
                    if node.r0_count == 0:
                        node.r0 = None
                else:
                    node.l0_count -= 1
                    if node.l0_count == 0:
                        node.l0 = None
            # If the node still has references or counts, break
            if (node.r1 or node.l1 or node.r0 or node.l0 or
                node.r1_count > 0 or node.l1_count > 0 or
                node.r0_count > 0 or node.l0_count > 0):
                break

def solve():
    # n = int(input())
    n,m  = list(map(int,input().split()))
    g = [[] for i in range(n+1)]
    for i in range(n-1) :
        u,v,w = list(map(int,input().split()))
        g[u].append((v,w))
        g[v].append((u,w))
    queries = [[] for i in range(n+1)]
    cur = 0
    j = 0

    for i in range(m) :
        query = list(map(str,input().split()))
        if query[0] == "^" :
            cur ^= int(query[1])
        else:
            v,x = [int(x) for x in query[1:]]
            queries[v].append((j,x,cur))
            j += 1

    ans = [0]*j
    q = [[1,0,-1,0]]

    xors = [0]*(n+1)
    odd = [0]*(n+1)
    while q :
        node,xor,par,num = q.pop()
        xors[node] = ((xor,num))
        odd[node] = num
        for ch ,w in g[node] :
            if ch != par   :
                q.append((ch,xor^w,node,num^1))

    trie = Trie()
    for i in range(1,n+1) :
        value,parity = xors[i]
        trie.insert(value,parity)

    for i in range(1,n+1) :
        for j,x,cur in queries[i] :

            current  = 0
            value,parity = xors[i]
            trie.delete(value,parity)
            # print(j,x,cur,i,xors,value^cur^x,parity)
            current = max(current,trie.query(value^x,parity) )
            current = max(current,trie.query(value^x^cur,parity^1) )

            trie.insert(value,parity)
            ans[j] = current

    print(*ans)

###############################################################################
###############################################################################
###############################################################################

for t in range(int(input())):
    # case(t+1)
    solve()

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the provided buggy code, we need to consider edge cases and scenarios that maximize the probability of failure. Here are the steps to create such a test input:

1. **Simple Tree Structure**: Start with a simple tree structure to ensure that the basic logic is tested.
2. **Queries to Test XOR Operations**: Include queries that involve multiple XOR operations to ensure the XOR logic is working correctly.
3. **Queries to Test Maximum XOR Calculation**: Include queries that require calculating the maximum XOR value for different vertices and weights.
4. **Edge Cases**: Include edge cases such as a tree with only two vertices, a tree with a large number of vertices, and queries with very large weights.

Given the constraints and the need for a small-scale test input, we can create a test case with a simple tree and a few queries to cover the essential logic.

Here is a small-scale test input:

```plaintext
1
4 5
1 2 3
2 3 5
3 4 7
^ 2
? 1 4
^ 3
? 2 6
? 4 1
```

### Explanation:
- **Tree Structure**:
  - Vertices: 1, 2, 3, 4
  - Edges: (1, 2, 3), (2, 3, 5), (3, 4, 7)

- **Queries**:
  - `^ 2`: XOR all edge weights with 2.
  - `? 1 4`: Calculate the maximum XOR value for vertex 1 with weight 4.
  - `^ 3`: XOR all edge weights with 3.
  - `? 2 6`: Calculate the maximum XOR value for vertex 2 with weight 6.
  - `? 4 1`: Calculate the maximum XOR value for vertex 4 with weight 1.

This test input is designed to:
- Test the XOR operations on edge weights.
- Test the maximum XOR value calculation for different vertices and weights.
- Ensure the Trie operations (insert, delete, query) are working correctly.

By running this test input, we can identify if the buggy code fails to handle these operations correctly.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Yasya and the Mysterious Tree
time_limit_ms: 2500
memory_limit_mb: 512
Description: Yasya was walking in the forest and accidentally found a tree with $n$ vertices. A tree is a connected undirected graph with no cycles.

Next to the tree, the girl found an ancient manuscript with $m$ queries written on it. The queries can be of two types.

The first type of query is described by the integer $y$. The weight of each edge in the tree is replaced by the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of the weight of that edge and the integer $y$.

The second type is described by the vertex $v$ and the integer $x$. Yasya chooses a vertex $u$ ($1 \le u \le n$, $u \neq v$) and mentally draws a bidirectional edge of weight $x$ from $v$ to $u$ in the tree.

Then Yasya finds a simple cycle in the resulting graph and calculates the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of all the edges in it. She wants to choose a vertex $u$ such that the calculated value is maximum. This calculated value will be the answer to the query. It can be shown that such a cycle exists and is unique under the given constraints (independent of the choice of $u$). If an edge between $v$ and $u$ already existed, a simple cycle is the path $v \to u \to v$.

Note that the second type of query is performed mentally, meaning the tree does not change in any way after it.

Help Yasya answer all the queries.

Input: The first line contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

The descriptions of the test cases follow.

The first line of each test case contains two integers $n$, $m$ ($2 \le n \le 2 \cdot 10^5$, $1 \le m \le 2 \cdot 10^5$) — the number of vertices in the tree and the number of queries.

The next $n - 1$ lines of each test case contain three integers $v$, $u$, $w$ ($1 \le v, u \le n$, $1 \le w \le 10^9$) — the ends of some edge in the tree and its weight.

It is guaranteed that the given set of edges forms a tree.

The next $m$ lines of each test case describe the queries:

  * ^ $y$ ($1 \le y \le 10^9$) — parameter of the first type query;    * ? $v$ $x$ ($1 \le v \le n$, $1 \le x \le 10^9$) — parameters of the second type query.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$. The same is guaranteed for $m$.

Output: For each test case, output the answers to the queries of the second type.

Examples:
input:
2
3 7
1 2 1
3 1 8
^ 5
? 2 9
^ 1
? 1 10
^ 6
? 3 1
? 2 9
5 6
1 2 777
3 2 2812
4 1 16
5 3 1000000000
^ 4
? 3 123
? 5 1000000000
^ 1000000000
? 1 908070
? 2 1
output:
13 15 11 10
1000000127 2812 999756331 999999756

input:
3
8 4
8 6 3
6 3 4
2 5 4
7 6 2
7 1 10
4 1 4
5 1 2
^ 4
^ 7
? 7 8
? 4 10
5 6
3 1 4
2 3 9
4 3 6
5 2 10
? 5 7
^ 1
^ 8
? 4 10
? 1 9
? 3 6
4 2
2 1 4
4 3 5
2 3 4
^ 13
? 1 10
output:
14 13
13 8 11 11
10

Note:

Buggy Code:
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Pro8 {

    static List<int[]>[] edges;
    static int[] f, d;

    public static void dfs(int u, int fa) {
        for (int[] to : edges[u]) {
            int v = to[0], w = to[1];
            if (v == fa) continue;
            d[v] = d[u] ^ 1;
            f[v] = f[u] ^ w;
            dfs(v, u);
        }
    }

    static int[][] trie, cnt;
    static int index;

    public static int newNode() {
        int x = ++index;
        trie[x][0] = trie[x][1] = 0;
        cnt[x][0] = cnt[x][1] = 0;
        return x;
    }

    public static void insert(int v, int q, int t) {
        int p = 1;
        cnt[p][q] += t;
        for (int i = 29; i >= 0; i--) {
            int bit = v >> i & 1;
            if (trie[p][bit] == 0) trie[p][bit] = newNode();
            p = trie[p][bit];
            cnt[p][q] += t;
        }
    }

    public static int query(int v, int q) {
        int ans = 0;
        int p = 1;
        if (cnt[p][q] == 0) return ans;
        for (int i = 29; i >= 0; i--) {
            int bit = v >> i & 1;
            if (cnt[trie[p][bit^1]][q] > 0) {
                ans |= 1 << i;
                p = trie[p][bit^1];
            }else {
                p = trie[p][bit];
            }
        }
        return ans;
    }

    public static void solve() throws IOException{
        int n = in.nextInt();
        int m = in.nextInt();
        edges = new ArrayList[n+1];
        Arrays.setAll(edges, e -> new ArrayList<>());
        for (int i = 0; i < n - 1; i++) {
            int u = in.nextInt();
            int v = in.nextInt();
            int w = in.nextInt();
            edges[u].add(new int[]{v, w});
            edges[v].add(new int[]{u, w});
        }
        f = new int[n+1];
        d = new int[n+1];
        dfs(1, 0);
        index = 0;
        int N = (int) 1e5;
        trie = new int[N][2];
        cnt = new int[N][2];
        newNode();
        for (int i = 1; i <= n; i++) insert(f[i], d[i], 1);
        int val = 0;
        for (int i = 0; i < m; i++) {
            String[] strings = in.nextLine().split(" ");
            char ch = strings[0].charAt(0);
            int x = Integer.parseInt(strings[1]);
            if (ch == '^') {
                val ^= x;
            }else {
                int y = Integer.parseInt(strings[2]);
                insert(f[x], d[x], -1);
                out.print(Math.max(query(f[x]^y, d[x]), query(f[x]^y^val, d[x]^1)) + " ");
                insert(f[x], d[x], 1);
            }
        }
        out.println();
    }

    static boolean MULTI_CASE = true;

    public static void main(String[] args) throws IOException {
        if (MULTI_CASE) {
            int T = in.nextInt();
            for (int i = 0; i < T; ++i) {
                solve();
            }
        } else {
            solve();
        }
        out.close();
    }

    static InputReader in = new InputReader();
    static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

    static class InputReader {
        private StringTokenizer st;
        private BufferedReader bf;

        public InputReader() {
            bf = new BufferedReader(new InputStreamReader(System.in));
            st = null;
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(bf.readLine());
            }
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            return bf.readLine();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
    }
}

/*

2 2 1 2 3 2 2 3
1 2 2 2 2 2 3 3

 */

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
2
3 3
1 2 1
2 3 1
^ 1
? 1 2
? 2 3
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Yasya and the Mysterious Tree
time_limit_ms: 2500
memory_limit_mb: 512
Description: Yasya was walking in the forest and accidentally found a tree with $n$ vertices. A tree is a connected undirected graph with no cycles.

Next to the tree, the girl found an ancient manuscript with $m$ queries written on it. The queries can be of two types.

The first type of query is described by the integer $y$. The weight of each edge in the tree is replaced by the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of the weight of that edge and the integer $y$.

The second type is described by the vertex $v$ and the integer $x$. Yasya chooses a vertex $u$ ($1 \le u \le n$, $u \neq v$) and mentally draws a bidirectional edge of weight $x$ from $v$ to $u$ in the tree.

Then Yasya finds a simple cycle in the resulting graph and calculates the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of all the edges in it. She wants to choose a vertex $u$ such that the calculated value is maximum. This calculated value will be the answer to the query. It can be shown that such a cycle exists and is unique under the given constraints (independent of the choice of $u$). If an edge between $v$ and $u$ already existed, a simple cycle is the path $v \to u \to v$.

Note that the second type of query is performed mentally, meaning the tree does not change in any way after it.

Help Yasya answer all the queries.

Input: The first line contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

The descriptions of the test cases follow.

The first line of each test case contains two integers $n$, $m$ ($2 \le n \le 2 \cdot 10^5$, $1 \le m \le 2 \cdot 10^5$) — the number of vertices in the tree and the number of queries.

The next $n - 1$ lines of each test case contain three integers $v$, $u$, $w$ ($1 \le v, u \le n$, $1 \le w \le 10^9$) — the ends of some edge in the tree and its weight.

It is guaranteed that the given set of edges forms a tree.

The next $m$ lines of each test case describe the queries:

  * ^ $y$ ($1 \le y \le 10^9$) — parameter of the first type query;    * ? $v$ $x$ ($1 \le v \le n$, $1 \le x \le 10^9$) — parameters of the second type query.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$. The same is guaranteed for $m$.

Output: For each test case, output the answers to the queries of the second type.

Examples:
input:
2
3 7
1 2 1
3 1 8
^ 5
? 2 9
^ 1
? 1 10
^ 6
? 3 1
? 2 9
5 6
1 2 777
3 2 2812
4 1 16
5 3 1000000000
^ 4
? 3 123
? 5 1000000000
^ 1000000000
? 1 908070
? 2 1
output:
13 15 11 10
1000000127 2812 999756331 999999756

input:
3
8 4
8 6 3
6 3 4
2 5 4
7 6 2
7 1 10
4 1 4
5 1 2
^ 4
^ 7
? 7 8
? 4 10
5 6
3 1 4
2 3 9
4 3 6
5 2 10
? 5 7
^ 1
^ 8
? 4 10
? 1 9
? 3 6
4 2
2 1 4
4 3 5
2 3 4
^ 13
? 1 10
output:
14 13
13 8 11 11
10

Note:

Buggy Code:
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Pro8 {

    static List<int[]>[] edges;
    static int[] f, d;

    public static void dfs(int u, int fa) {
        for (int[] to : edges[u]) {
            int v = to[0], w = to[1];
            if (v == fa) continue;
            d[v] = d[u] ^ 1;
            f[v] = f[u] ^ w;
            dfs(v, u);
        }
    }

    static int[][] trie, cnt;
    static int index;

    public static int newNode() {
        int x = ++index;
        trie[x][0] = trie[x][1] = 0;
        cnt[x][0] = cnt[x][1] = 0;
        return x;
    }

    public static void insert(int v, int q, int t) {
        int p = 1;
        cnt[p][q] += t;
        for (int i = 29; i >= 0; i--) {
            int bit = v >> i & 1;
            if (trie[p][bit] == 0) trie[p][bit] = newNode();
            p = trie[p][bit];
            cnt[p][q] += t;
        }
    }

    public static int query(int v, int q) {
        int ans = 0;
        int p = 1;
        if (cnt[p][q] == 0) return ans;
        for (int i = 29; i >= 0; i--) {
            int bit = v >> i & 1;
            if (cnt[trie[p][bit^1]][q] > 0) {
                ans |= 1 << i;
                p = trie[p][bit^1];
            }else {
                p = trie[p][bit];
            }
        }
        return ans;
    }

    public static void solve() throws IOException{
        int n = in.nextInt();
        int m = in.nextInt();
        edges = new ArrayList[n+1];
        Arrays.setAll(edges, e -> new ArrayList<>());
        for (int i = 0; i < n - 1; i++) {
            int u = in.nextInt();
            int v = in.nextInt();
            int w = in.nextInt();
            edges[u].add(new int[]{v, w});
            edges[v].add(new int[]{u, w});
        }
        f = new int[n+1];
        d = new int[n+1];
        dfs(1, 0);
        index = 0;
        int N = (int) 1e6;
        trie = new int[N][2];
        cnt = new int[N][2];
        newNode();
        for (int i = 1; i <= n; i++) insert(f[i], d[i], 1);
        int val = 0;
        for (int i = 0; i < m; i++) {
            String[] strings = in.nextLine().split(" ");
            char ch = strings[0].charAt(0);
            int x = Integer.parseInt(strings[1]);
            if (ch == '^') {
                val ^= x;
            }else {
                int y = Integer.parseInt(strings[2]);
                insert(f[x], d[x], -1);
                out.print(Math.max(query(f[x]^y, d[x]), query(f[x]^y^val, d[x]^1)) + " ");
                insert(f[x], d[x], 1);
            }
        }
        out.println();
    }

    static boolean MULTI_CASE = true;

    public static void main(String[] args) throws IOException {
        if (MULTI_CASE) {
            int T = in.nextInt();
            for (int i = 0; i < T; ++i) {
                solve();
            }
        } else {
            solve();
        }
        out.close();
    }

    static InputReader in = new InputReader();
    static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

    static class InputReader {
        private StringTokenizer st;
        private BufferedReader bf;

        public InputReader() {
            bf = new BufferedReader(new InputStreamReader(System.in));
            st = null;
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(bf.readLine());
            }
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            return bf.readLine();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
    }
}

/*

2 2 1 2 3 2 2 3
1 2 2 2 2 2 3 3

 */

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
2
3 4
1 2 1
3 1 8
^ 5
? 2 9
^ 1
? 1 10
4 5
1 2 1
2 3 2
3 4 4
^ 3
? 2 5
^ 7
? 3 6
? 1 8
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Yasya and the Mysterious Tree
time_limit_ms: 2500
memory_limit_mb: 512
Description: Yasya was walking in the forest and accidentally found a tree with $n$ vertices. A tree is a connected undirected graph with no cycles.

Next to the tree, the girl found an ancient manuscript with $m$ queries written on it. The queries can be of two types.

The first type of query is described by the integer $y$. The weight of each edge in the tree is replaced by the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of the weight of that edge and the integer $y$.

The second type is described by the vertex $v$ and the integer $x$. Yasya chooses a vertex $u$ ($1 \le u \le n$, $u \neq v$) and mentally draws a bidirectional edge of weight $x$ from $v$ to $u$ in the tree.

Then Yasya finds a simple cycle in the resulting graph and calculates the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of all the edges in it. She wants to choose a vertex $u$ such that the calculated value is maximum. This calculated value will be the answer to the query. It can be shown that such a cycle exists and is unique under the given constraints (independent of the choice of $u$). If an edge between $v$ and $u$ already existed, a simple cycle is the path $v \to u \to v$.

Note that the second type of query is performed mentally, meaning the tree does not change in any way after it.

Help Yasya answer all the queries.

Input: The first line contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

The descriptions of the test cases follow.

The first line of each test case contains two integers $n$, $m$ ($2 \le n \le 2 \cdot 10^5$, $1 \le m \le 2 \cdot 10^5$) — the number of vertices in the tree and the number of queries.

The next $n - 1$ lines of each test case contain three integers $v$, $u$, $w$ ($1 \le v, u \le n$, $1 \le w \le 10^9$) — the ends of some edge in the tree and its weight.

It is guaranteed that the given set of edges forms a tree.

The next $m$ lines of each test case describe the queries:

  * ^ $y$ ($1 \le y \le 10^9$) — parameter of the first type query;    * ? $v$ $x$ ($1 \le v \le n$, $1 \le x \le 10^9$) — parameters of the second type query.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$. The same is guaranteed for $m$.

Output: For each test case, output the answers to the queries of the second type.

Examples:
input:
2
3 7
1 2 1
3 1 8
^ 5
? 2 9
^ 1
? 1 10
^ 6
? 3 1
? 2 9
5 6
1 2 777
3 2 2812
4 1 16
5 3 1000000000
^ 4
? 3 123
? 5 1000000000
^ 1000000000
? 1 908070
? 2 1
output:
13 15 11 10
1000000127 2812 999756331 999999756

input:
3
8 4
8 6 3
6 3 4
2 5 4
7 6 2
7 1 10
4 1 4
5 1 2
^ 4
^ 7
? 7 8
? 4 10
5 6
3 1 4
2 3 9
4 3 6
5 2 10
? 5 7
^ 1
^ 8
? 4 10
? 1 9
? 3 6
4 2
2 1 4
4 3 5
2 3 4
^ 13
? 1 10
output:
14 13
13 8 11 11
10

Note:

Buggy Code:
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int MAXN = 2e5 + 5;

vector<pair<int, int>> g[MAXN];
int T, n, m, q, d[MAXN], son[MAXN * 32][2], c[MAXN], s[MAXN];

void Insert(int x, int r, int v) {
  for (int u = r, i = 29; i >= 0; i--) {
    int now = (x >> i) & 1;
    if (!son[u][now]) {
      son[u][now] = ++m;
    }
    u = son[u][now], c[u] += v;
  }
}

int query(int x, int r) {
  int ret = 0;
  for (int u = r, i = 29; i >= 0; i--) {
    int now = (x >> i) & 1;
    if (c[son[u][now ^ 1]]) {
      ret += (1 << i), u = son[u][now ^ 1];
    } else {
      u = son[u][now];
    }
  }
  return ret;
}

void dfs(int x, int fx) {
  Insert(s[x], (d[x] & 1) + 1, 1);
  for (auto [y, w] : g[x]) {
    if (y != fx) {
      s[y] = s[x] ^ w;
      d[y] = d[x] + 1, dfs(y, x);
    }
  }
}

void Solve() {
  cin >> n >> q, m = 2;
  for (int i = 1, u, v, w; i < n; i++) {
    cin >> u >> v >> w;
    g[u].push_back({v, w});
    g[v].push_back({u, w});
  }
  dfs(1, 0);
  for (int sum = 0, u, x; q--; ) {
    char op; cin >> op;
    if (op == '^') {
      cin >> x, sum ^= x;
    } else {
      cin >> u >> x;
      int k = s[u] ^ (d[u] & 1 ? sum : 0) ^ x;
      Insert(s[u], (d[u] & 1) + 1, -1);
      cout << max(query((k ^ sum), 2), query(k, 1)) << ' ';
      Insert(s[u], (d[u] & 1) + 1, 1);
    }
  }
  cout << '\n';
  for (int i = 1; i <= n; i++) {
    g[i].clear();
  }
  for (; m; son[m][0] = son[m][1] = c[m] = 0, m--);
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  for (cin >> T; T--; ) {
    Solve();
  }
  return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
2
3 7
1 2 1
3 1 8
^ 5
? 2 9
^ 1
? 1 10
^ 6
? 3 1
? 2 9
5 6
1 2 777
3 2 2812
4 1 16
5 3 1000000000
^ 4
? 3 123
? 5 1000000000
^ 1000000000
? 1 908070
? 2 1
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Yasya and the Mysterious Tree
time_limit_ms: 2500
memory_limit_mb: 512
Description: Yasya was walking in the forest and accidentally found a tree with $n$ vertices. A tree is a connected undirected graph with no cycles.

Next to the tree, the girl found an ancient manuscript with $m$ queries written on it. The queries can be of two types.

The first type of query is described by the integer $y$. The weight of each edge in the tree is replaced by the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of the weight of that edge and the integer $y$.

The second type is described by the vertex $v$ and the integer $x$. Yasya chooses a vertex $u$ ($1 \le u \le n$, $u \neq v$) and mentally draws a bidirectional edge of weight $x$ from $v$ to $u$ in the tree.

Then Yasya finds a simple cycle in the resulting graph and calculates the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of all the edges in it. She wants to choose a vertex $u$ such that the calculated value is maximum. This calculated value will be the answer to the query. It can be shown that such a cycle exists and is unique under the given constraints (independent of the choice of $u$). If an edge between $v$ and $u$ already existed, a simple cycle is the path $v \to u \to v$.

Note that the second type of query is performed mentally, meaning the tree does not change in any way after it.

Help Yasya answer all the queries.

Input: The first line contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

The descriptions of the test cases follow.

The first line of each test case contains two integers $n$, $m$ ($2 \le n \le 2 \cdot 10^5$, $1 \le m \le 2 \cdot 10^5$) — the number of vertices in the tree and the number of queries.

The next $n - 1$ lines of each test case contain three integers $v$, $u$, $w$ ($1 \le v, u \le n$, $1 \le w \le 10^9$) — the ends of some edge in the tree and its weight.

It is guaranteed that the given set of edges forms a tree.

The next $m$ lines of each test case describe the queries:

  * ^ $y$ ($1 \le y \le 10^9$) — parameter of the first type query;    * ? $v$ $x$ ($1 \le v \le n$, $1 \le x \le 10^9$) — parameters of the second type query.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$. The same is guaranteed for $m$.

Output: For each test case, output the answers to the queries of the second type.

Examples:
input:
2
3 7
1 2 1
3 1 8
^ 5
? 2 9
^ 1
? 1 10
^ 6
? 3 1
? 2 9
5 6
1 2 777
3 2 2812
4 1 16
5 3 1000000000
^ 4
? 3 123
? 5 1000000000
^ 1000000000
? 1 908070
? 2 1
output:
13 15 11 10
1000000127 2812 999756331 999999756

input:
3
8 4
8 6 3
6 3 4
2 5 4
7 6 2
7 1 10
4 1 4
5 1 2
^ 4
^ 7
? 7 8
? 4 10
5 6
3 1 4
2 3 9
4 3 6
5 2 10
? 5 7
^ 1
^ 8
? 4 10
? 1 9
? 3 6
4 2
2 1 4
4 3 5
2 3 4
^ 13
? 1 10
output:
14 13
13 8 11 11
10

Note:

Buggy Code:
#include <bits/stdc++.h>
using namespace std;

#define fastIO ios_base::sync_with_stdio(0);cin.tie(0), cout.tie(0);
#define ll long long
#define fo(i, n) for (decltype(n) i = 0; i < n; i++)
#define re(i, n) for (decltype(n) i = n - 1; i >= 0; i--)
#define fo1(i, a, b) for (decltype(n) i = a; i < b; i++)
#define re1(i, a, b) for (decltype(n) i = a; i >= b; i--)
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pb push_back
#define read(a, n)              \
    for (int i = 0; i < n; ++i) \
        cin >> a[i];
#define print_space(a, n)         \
    for (int i = 0; i < n; ++i)   \
        if (i == n - 1)           \
        {                         \
            cout << a[i] << "\n"; \
        }                         \
        else                      \
        {                         \
            cout << a[i] << ' ';  \
        }
#define fill(v,n,val) fill(v.begin(),v.begin()+n,val)
#define L cout << "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define is_possible cout << ((possible) ? "YES\n": "NO\n")

const long long INF=2e5+500;
const long long MOD=0;
int16_t n,q;

vector<int> e(2*INF,0);
vector<int> ne(2*INF,0);
vector<int> h(INF,-1);
vector<bool> vis(INF,0);
vector<int> w(2*INF,0);
vector<int> dep(INF,0);
vector<int> xr(INF,0);
vector<vector<int>> nv(INF*30,vector<int>(2,0));
vector<int> tag(INF,0);
int idx=0,cnt=1;

void add(int a,int b,int c)
{
    e[idx]=b;
    ne[idx]=h[a];
    h[a]=idx;
    w[idx]=c;
    idx++;
}

void dfs(int v,int d,int ed)
{
    vis[v]=1;
    xr[v]=ed;
    dep[v]=d;
    if (v!=1 && ne[h[v]]==-1) return;
    for(int i=h[v];i!=-1;i=ne[i])
    {
        if (not vis[e[i]]) dfs(e[i],d+1,ed^w[i]);
    }
    return ;
}

void insert_key(int x,int p,int id)
{
    if (tag[p]) tag[p]=-1;
    else tag[p]=id;
    for(int i=29;i>=0;i--)
    {
        int ch=(x>>i)&1;
        if(nv[p][ch]==0) nv[p][ch]=++cnt;
        p=nv[p][ch];
        if (tag[p]) tag[p]=-1;
        else tag[p]=id;
    }
}

int search_key(int x,int p,int id)
{
    int res=0;
    for(int i=29;i>=0;i--)
    {
        int ch=(x>>i)&1;
        if(nv[p][!ch] && tag[nv[p][!ch]]!=id) {p=nv[p][!ch];res+=(ll)pow(2,i);}
        else p=nv[p][ch];
    }
    return res;
}

void solve()
{
    cin>>n>>q;
    fill(e,2*n+10,0);
    fill(ne,2*n+10,0);
    fill(h,n+5,-1);
    fill(w,2*n+10,0);
    fill(xr,n+5,0);
    fill(vis,n+5,0);
    fill(dep,n+5,0);
    fill(tag,n*30+50,0);
    fill(nv,n*30+50,vector<int>(2,0));
    idx=0,cnt=1;
    int a,b,c;
    fo(i,n-1){ cin>>a>>b>>c;add(a,b,c);add(b,a,c);}
    dfs(1,0,0);
    fo1(i,1,n+1) {insert_key(xr[i],dep[i]&1,i);}
    ll xo=0;
    fo(i,q) {
        char c;
        cin>>c;
        if(c=='^'){
            ll num;
            cin>>num;
            xo^=num;
        }
        else if(c=='?'){
            int v,x;
            cin>>v>>x;
            int d=xr[v];
            if (dep[v]&1) d^=xo;
            int res=0;
            if (tag[0]!=v) res=max(res,search_key(d^x,0,v));
            if (tag[1]!=v) res=max(res,search_key(d^x^xo,1,v));
            cout<<res<<' ';
        }
    }
    L;
}

int main()
{
    fastIO;
    int N;
    cin>>N;
    while(N--)
    {
        solve();
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
2
3 5
1 2 1
3 1 8
^ 5
? 2 9
^ 1
? 1 10
? 3 1
4 6
1 2 1
2 3 2
3 4 3
^ 4
? 2 5
? 3 6
^ 7
? 1 8
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Yasya and the Mysterious Tree
time_limit_ms: 2500
memory_limit_mb: 512
Description: Yasya was walking in the forest and accidentally found a tree with $n$ vertices. A tree is a connected undirected graph with no cycles.

Next to the tree, the girl found an ancient manuscript with $m$ queries written on it. The queries can be of two types.

The first type of query is described by the integer $y$. The weight of each edge in the tree is replaced by the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of the weight of that edge and the integer $y$.

The second type is described by the vertex $v$ and the integer $x$. Yasya chooses a vertex $u$ ($1 \le u \le n$, $u \neq v$) and mentally draws a bidirectional edge of weight $x$ from $v$ to $u$ in the tree.

Then Yasya finds a simple cycle in the resulting graph and calculates the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of all the edges in it. She wants to choose a vertex $u$ such that the calculated value is maximum. This calculated value will be the answer to the query. It can be shown that such a cycle exists and is unique under the given constraints (independent of the choice of $u$). If an edge between $v$ and $u$ already existed, a simple cycle is the path $v \to u \to v$.

Note that the second type of query is performed mentally, meaning the tree does not change in any way after it.

Help Yasya answer all the queries.

Input: The first line contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

The descriptions of the test cases follow.

The first line of each test case contains two integers $n$, $m$ ($2 \le n \le 2 \cdot 10^5$, $1 \le m \le 2 \cdot 10^5$) — the number of vertices in the tree and the number of queries.

The next $n - 1$ lines of each test case contain three integers $v$, $u$, $w$ ($1 \le v, u \le n$, $1 \le w \le 10^9$) — the ends of some edge in the tree and its weight.

It is guaranteed that the given set of edges forms a tree.

The next $m$ lines of each test case describe the queries:

  * ^ $y$ ($1 \le y \le 10^9$) — parameter of the first type query;    * ? $v$ $x$ ($1 \le v \le n$, $1 \le x \le 10^9$) — parameters of the second type query.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$. The same is guaranteed for $m$.

Output: For each test case, output the answers to the queries of the second type.

Examples:
input:
2
3 7
1 2 1
3 1 8
^ 5
? 2 9
^ 1
? 1 10
^ 6
? 3 1
? 2 9
5 6
1 2 777
3 2 2812
4 1 16
5 3 1000000000
^ 4
? 3 123
? 5 1000000000
^ 1000000000
? 1 908070
? 2 1
output:
13 15 11 10
1000000127 2812 999756331 999999756

input:
3
8 4
8 6 3
6 3 4
2 5 4
7 6 2
7 1 10
4 1 4
5 1 2
^ 4
^ 7
? 7 8
? 4 10
5 6
3 1 4
2 3 9
4 3 6
5 2 10
? 5 7
^ 1
^ 8
? 4 10
? 1 9
? 3 6
4 2
2 1 4
4 3 5
2 3 4
^ 13
? 1 10
output:
14 13
13 8 11 11
10

Note:

Buggy Code:
t = int(input())

class Trie:
    def __init__(self):
        self.child = {}
        self.ctr = 0

    def increase(self, number):
        cur = self
        cur.ctr += 1
        for i in range(31, -1, -1):
            bit = (number >> i) & 1
            if bit not in cur.child:
                cur.child[bit] = Trie()
            cur = cur.child[bit]
            cur.ctr += 1

    def findMax(self, number):
        cur, ans = self, 0
        for i in range(31, -1, -1):
            bit = (number >> i) & 1
            if (1-bit) in cur.child and cur.child[1 - bit].ctr:
                cur = cur.child[1 - bit]
                ans |= (1 << i)
            elif bit in cur.child and cur.child[bit].ctr:
                cur = cur.child[bit]
            else:
                return 0
        return ans

    def delete(self, number):
        cur = self
        cur.ctr -= 1
        for i in range(31, -1, -1):
            bit = (number >> i) & 1
            cur = cur.child[bit]
            cur.ctr -= 1

for _ in range(t):
    n, q = map(int, input().split())
    graph = [[] for _ in range(n)]
    for _ in range(n - 1):
        u, v, w = map(int, input().split())
        graph[u - 1].append((v - 1, w))
        graph[v - 1].append((u - 1, w))
    stack = [(0, -1, 0, 0)]
    xors = [0] * n
    depths = [0] * n
    while stack:
        i, prev, x, l = stack.pop()
        xors[i] = x
        depths[i] = l
        for j, w in graph[i]:
            if j != prev:
                stack.append((j, i, x ^ w, l + 1))
    oddtrie = Trie()
    eventrie = Trie()
    for i in range(n):
        if depths[i] % 2 == 0:
            eventrie.increase(xors[i])
        else:
            oddtrie.increase(xors[i])
    txor = 0
    res = []
    for _ in range(q):
        curr = input().split()
        if curr[0] == '^':
            txor ^= int(curr[1])
        else:
            v, x = int(curr[1]) - 1, int(curr[2])
            currval = 0
            if depths[v] % 2 == 0:
                eventrie.delete(xors[v])
                currval = max(currval, eventrie.findMax(xors[v] ^ x), oddtrie.findMax(xors[v] ^ x ^ txor))
                eventrie.increase(xors[v])
            else:
                oddtrie.delete(xors[v])
                currval = max(currval, eventrie.findMax(xors[v] ^ x ^ txor), oddtrie.findMax(xors[v] ^ x))
                oddtrie.increase(xors[v])
            res.append(currval)
    print(*res)

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
4 4
1 2 1
2 3 2
3 4 3
^ 1
? 1 10
? 2 10
? 3 10
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Yasya and the Mysterious Tree
time_limit_ms: 2500
memory_limit_mb: 512
Description: Yasya was walking in the forest and accidentally found a tree with $n$ vertices. A tree is a connected undirected graph with no cycles.

Next to the tree, the girl found an ancient manuscript with $m$ queries written on it. The queries can be of two types.

The first type of query is described by the integer $y$. The weight of each edge in the tree is replaced by the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of the weight of that edge and the integer $y$.

The second type is described by the vertex $v$ and the integer $x$. Yasya chooses a vertex $u$ ($1 \le u \le n$, $u \neq v$) and mentally draws a bidirectional edge of weight $x$ from $v$ to $u$ in the tree.

Then Yasya finds a simple cycle in the resulting graph and calculates the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of all the edges in it. She wants to choose a vertex $u$ such that the calculated value is maximum. This calculated value will be the answer to the query. It can be shown that such a cycle exists and is unique under the given constraints (independent of the choice of $u$). If an edge between $v$ and $u$ already existed, a simple cycle is the path $v \to u \to v$.

Note that the second type of query is performed mentally, meaning the tree does not change in any way after it.

Help Yasya answer all the queries.

Input: The first line contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

The descriptions of the test cases follow.

The first line of each test case contains two integers $n$, $m$ ($2 \le n \le 2 \cdot 10^5$, $1 \le m \le 2 \cdot 10^5$) — the number of vertices in the tree and the number of queries.

The next $n - 1$ lines of each test case contain three integers $v$, $u$, $w$ ($1 \le v, u \le n$, $1 \le w \le 10^9$) — the ends of some edge in the tree and its weight.

It is guaranteed that the given set of edges forms a tree.

The next $m$ lines of each test case describe the queries:

  * ^ $y$ ($1 \le y \le 10^9$) — parameter of the first type query;    * ? $v$ $x$ ($1 \le v \le n$, $1 \le x \le 10^9$) — parameters of the second type query.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$. The same is guaranteed for $m$.

Output: For each test case, output the answers to the queries of the second type.

Examples:
input:
2
3 7
1 2 1
3 1 8
^ 5
? 2 9
^ 1
? 1 10
^ 6
? 3 1
? 2 9
5 6
1 2 777
3 2 2812
4 1 16
5 3 1000000000
^ 4
? 3 123
? 5 1000000000
^ 1000000000
? 1 908070
? 2 1
output:
13 15 11 10
1000000127 2812 999756331 999999756

input:
3
8 4
8 6 3
6 3 4
2 5 4
7 6 2
7 1 10
4 1 4
5 1 2
^ 4
^ 7
? 7 8
? 4 10
5 6
3 1 4
2 3 9
4 3 6
5 2 10
? 5 7
^ 1
^ 8
? 4 10
? 1 9
? 3 6
4 2
2 1 4
4 3 5
2 3 4
^ 13
? 1 10
output:
14 13
13 8 11 11
10

Note:

Buggy Code:
from sys import *
input = stdin.readline
inputlist = lambda: map(int, stdin.readline().split())

def solvetree(tree, value, node):
    ans = 0
    current = tree
    for bit in reversed(range(30)):
        atbit = (value >> bit) & 1
        if current is None: return ans
        if current[1][1-atbit] is not None and current[1][1-atbit][0] != set([node]):
            ans += (1 << bit)
            current = current[1][1-atbit]
        else: current = current[1][atbit]
    return ans

def solve():
    n, m = inputlist()
    graph = [[] for _ in range(n+1)]
    for _ in range(n-1):
        a, b, weight = inputlist()
        graph[a].append((b, weight))
        graph[b].append((a, weight))

    current = [1]
    parity = 1
    visited = [-1] * (n+1)
    xors = [None] * (n+1)
    visited[1] = 0
    xors[1] = 0
    while current:
        newcurrent = []
        for node in current:
            for child, weight in graph[node]:
                if visited[child] == -1:
                    visited[child] = parity
                    xors[child] = xors[node] ^ weight
                    newcurrent.append(child)
        current = newcurrent
        parity = 1 - parity

    even = []
    odd = []
    for node in range(1, n+1):
        if visited[node] == 1: odd.append((node, xors[node]))
        else: even.append((node, xors[node]))
    eventree = (set(), [None, None])
    oddtree = (set(), [None, None])
    for node, value in even:
        current = eventree
        for bit in reversed(range(30)):
            atbit = (value >> bit) & 1
            if current[1][atbit] is None:
                current[1][atbit] = (set(), [None, None])
            current = current[1][atbit]
            current[0].add(node)
    for node, value in odd:
        current = oddtree
        for bit in reversed(range(30)):
            atbit = (value >> bit) & 1
            if current[1][atbit] is None:
                current[1][atbit] = (set(), [None, None])
            current = current[1][atbit]
            current[0].add(node)

    ans = []
    accumulate = 0
    for _ in range(m):
        info = stdin.readline().split()
        if len(info) == 2: accumulate ^= int(info[1])
        else:
            if visited[int(info[1])] == 0: ans.append(max(solvetree(eventree, int(info[2])^xors[int(info[1])], int(info[1])), solvetree(oddtree, int(info[2])^accumulate^xors[int(info[1])], int(info[1]))))
            else: ans.append(max(solvetree(eventree, int(info[2])^accumulate^xors[int(info[1])], int(info[1])), solvetree(oddtree, int(info[2])^xors[int(info[1])], int(info[1]))))
    return ans

for _ in range(int(input())):
    print(*solve())

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
2
3 3
1 2 1
3 1 8
^ 5
? 2 9
? 1 10
5 4
1 2 777
3 2 2812
4 1 16
5 3 1000000000
^ 4
? 3 123
? 5 1000000000
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Yasya and the Mysterious Tree
time_limit_ms: 2500
memory_limit_mb: 512
Description: Yasya was walking in the forest and accidentally found a tree with $n$ vertices. A tree is a connected undirected graph with no cycles.

Next to the tree, the girl found an ancient manuscript with $m$ queries written on it. The queries can be of two types.

The first type of query is described by the integer $y$. The weight of each edge in the tree is replaced by the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of the weight of that edge and the integer $y$.

The second type is described by the vertex $v$ and the integer $x$. Yasya chooses a vertex $u$ ($1 \le u \le n$, $u \neq v$) and mentally draws a bidirectional edge of weight $x$ from $v$ to $u$ in the tree.

Then Yasya finds a simple cycle in the resulting graph and calculates the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of all the edges in it. She wants to choose a vertex $u$ such that the calculated value is maximum. This calculated value will be the answer to the query. It can be shown that such a cycle exists and is unique under the given constraints (independent of the choice of $u$). If an edge between $v$ and $u$ already existed, a simple cycle is the path $v \to u \to v$.

Note that the second type of query is performed mentally, meaning the tree does not change in any way after it.

Help Yasya answer all the queries.

Input: The first line contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

The descriptions of the test cases follow.

The first line of each test case contains two integers $n$, $m$ ($2 \le n \le 2 \cdot 10^5$, $1 \le m \le 2 \cdot 10^5$) — the number of vertices in the tree and the number of queries.

The next $n - 1$ lines of each test case contain three integers $v$, $u$, $w$ ($1 \le v, u \le n$, $1 \le w \le 10^9$) — the ends of some edge in the tree and its weight.

It is guaranteed that the given set of edges forms a tree.

The next $m$ lines of each test case describe the queries:

  * ^ $y$ ($1 \le y \le 10^9$) — parameter of the first type query;    * ? $v$ $x$ ($1 \le v \le n$, $1 \le x \le 10^9$) — parameters of the second type query.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$. The same is guaranteed for $m$.

Output: For each test case, output the answers to the queries of the second type.

Examples:
input:
2
3 7
1 2 1
3 1 8
^ 5
? 2 9
^ 1
? 1 10
^ 6
? 3 1
? 2 9
5 6
1 2 777
3 2 2812
4 1 16
5 3 1000000000
^ 4
? 3 123
? 5 1000000000
^ 1000000000
? 1 908070
? 2 1
output:
13 15 11 10
1000000127 2812 999756331 999999756

input:
3
8 4
8 6 3
6 3 4
2 5 4
7 6 2
7 1 10
4 1 4
5 1 2
^ 4
^ 7
? 7 8
? 4 10
5 6
3 1 4
2 3 9
4 3 6
5 2 10
? 5 7
^ 1
^ 8
? 4 10
? 1 9
? 3 6
4 2
2 1 4
4 3 5
2 3 4
^ 13
? 1 10
output:
14 13
13 8 11 11
10

Note:

Buggy Code:
// Generated by Code Flattener.
// https://plugins.jetbrains.com/plugin/9979-idea-code-flattener

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import static java.lang.Math.max;

public class Main {
    public static void main(String[] args) {
        Solution obj = new Solution();
        obj.invoke();
    }

    private static class Solution {
        private final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        private final static PrintWriter out = new PrintWriter(System.out);
        private StringTokenizer st = new StringTokenizer("");
        private boolean multiCase = true;

        public void invoke() {
            int t = 1;
            if (multiCase) t = nextInt();
            while (t-- > 0) {
                solve();
            }
            out.flush();
        }

        private int N = (int) 2e5 + 1;
        private int[][] trie = new int[2][N];
        private int[][] cnt = new int[2][N];
        private int total;

        private int newNode() {
            int x = ++total;
            trie[0][x] = trie[1][x] = 0;
            cnt[0][x] = cnt[1][x] = 0;
            return x;
        }

        private void add(int v, int q, int t) {
            int p = 1;
            cnt[q][p] += t;
            for (int i = 29; i >= 0; i--) {
                int bit = v >> i & 1;
                if (trie[bit][p] == 0) trie[bit][p] = newNode();
                p = trie[bit][p];
                cnt[q][p] += t;
            }
        }

        private int findMax(int v, int q) {
            int ans = 0;
            int p = 1;
            if (cnt[q][p] == 0) return ans;
            for (int i = 29; i >= 0; i--) {
                int bit = v >> i & 1;
                if (cnt[q][trie[bit ^ 1][p]] > 0) {
                    ans |= 1 << i;
                    p = trie[bit ^ 1][p];
                } else {
                    p = trie[bit][p];
                }
            }
            return ans;
        }

        private void solve() {
            int n = nextInt();
            int m = nextInt();
            List<int[]>[] graph = buildGraph(n);
            int[] oddDepth = new int[n];
            int[] xorDp = new int[n];
            dfs(0, 0, oddDepth, xorDp, graph);
            total = 0;
            newNode();
            for (int i = 0; i < n; i++) {
                add(xorDp[i], oddDepth[i], 1);
            }
            int addedXor = 0;
            while (m-- > 0) {
                char ch = nextChar();
                if (ch == '^') {
                    int y = nextInt();
                    addedXor ^= y;
                } else {
                    int v = nextInt() - 1;
                    int x = nextInt();
                    int ans = 0;
                    add(xorDp[v], oddDepth[v], -1);
                    ans = max(ans, max(findMax(xorDp[v] ^ x, oddDepth[v]), findMax(xorDp[v] ^ x ^ addedXor, oddDepth[v] ^ 1)));
                    add(xorDp[v], oddDepth[v], 1);
                    print(ans);
                }
            }
            println();
        }

        private void dfs(int node, int parent, int[] oddDepth, int[] xorDp, List<int[]>[] graph) {
            for (int[] adjNode : graph[node]) {
                int child = adjNode[0], wt = adjNode[1];
                if (child == parent) continue;
                oddDepth[child] = oddDepth[node] ^ 1;
                xorDp[child] = xorDp[node] ^ wt;
                dfs(child, node, oddDepth, xorDp, graph);
            }
        }

        private List<int[]>[] buildGraph(int n) {
            List<int[]>[] graph = new List[n];
            for (int i = 0; i < n; i++) {
                graph[i] = new ArrayList<>();
            }
            for (int i = 1; i < n; i++) {
                int u = nextInt() - 1;
                int v = nextInt() - 1;
                int w = nextInt();
                graph[u].add(new int[]{v, w});
                graph[v].add(new int[]{u, w});
            }
            return graph;
        }

        public String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public void print(Object... str) {
            for (Object s : str)
                out.print(s + " ");
        }

        public void println(Object... str) {
            for (Object s : str)
                print(s);
            out.println();
        }
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
2
3 7
1 2 1
3 1 8
^ 5
? 2 9
^ 1
? 1 10
^ 6
? 3 1
? 2 9
5 6
1 2 777
3 2 2812
4 1 16
5 3 1000000000
^ 4
? 3 123
? 5 1000000000
^ 1000000000
? 1 908070
? 2 1
```

### Explanation:
1. **Test Case 1:**
   - **Tree:**
     - Edges: (1, 2, 1), (3, 1, 8)
   - **Queries:**
     - **Query 1:** `^ 5` (XOR all edge weights with 5)
     - **Query 2:** `? 2 9` (Find the maximum XOR value for a cycle starting from vertex 2 with edge weight 9)
     - **Query 3:** `^ 1` (XOR all edge weights with 1)
     - **Query 4:** `? 1 10` (Find the maximum XOR value for a cycle starting from vertex 1 with edge weight 10)
     - **Query 5:** `^ 6` (XOR all edge weights with 6)
     - **Query 6:** `? 3 1` (Find the maximum XOR value for a cycle starting from vertex 3 with edge weight 1)
     - **Query 7:** `? 2 9` (Find the maximum XOR value for a cycle starting from vertex 2 with edge weight 9)

2. **Test Case 2:**
   - **Tree:**
     - Edges: (1, 2, 777), (3, 2, 2812), (4, 1, 16), (5, 3, 1000000000)
   - **Queries:**
     - **Query 1:** `^ 4` (XOR all edge weights with 4)
     - **Query 2:** `? 3 123` (Find the maximum XOR value for a cycle starting from vertex 3 with edge weight 123)
     - **Query 3:** `? 5 1000000000` (Find the maximum XOR value for a cycle starting from vertex 5 with edge weight 1000000000)
     - **Query 4:** `^ 1000000000` (XOR all edge weights with 1000000000)
     - **Query 5:** `? 1 908070` (Find the maximum XOR value for a cycle starting from vertex 1 with edge weight 908070)
     - **Query 6:** `? 2 1` (Find the maximum XOR value for a cycle starting from vertex 2 with edge weight 1)

This test input is designed to cover various edge cases and scenarios that could expose bugs in the given buggy code. It includes multiple test cases, different types of queries, and large numbers to ensure the algorithm handles large values correctly.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Yasya and the Mysterious Tree
time_limit_ms: 2500
memory_limit_mb: 512
Description: Yasya was walking in the forest and accidentally found a tree with $n$ vertices. A tree is a connected undirected graph with no cycles.

Next to the tree, the girl found an ancient manuscript with $m$ queries written on it. The queries can be of two types.

The first type of query is described by the integer $y$. The weight of each edge in the tree is replaced by the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of the weight of that edge and the integer $y$.

The second type is described by the vertex $v$ and the integer $x$. Yasya chooses a vertex $u$ ($1 \le u \le n$, $u \neq v$) and mentally draws a bidirectional edge of weight $x$ from $v$ to $u$ in the tree.

Then Yasya finds a simple cycle in the resulting graph and calculates the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of all the edges in it. She wants to choose a vertex $u$ such that the calculated value is maximum. This calculated value will be the answer to the query. It can be shown that such a cycle exists and is unique under the given constraints (independent of the choice of $u$). If an edge between $v$ and $u$ already existed, a simple cycle is the path $v \to u \to v$.

Note that the second type of query is performed mentally, meaning the tree does not change in any way after it.

Help Yasya answer all the queries.

Input: The first line contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

The descriptions of the test cases follow.

The first line of each test case contains two integers $n$, $m$ ($2 \le n \le 2 \cdot 10^5$, $1 \le m \le 2 \cdot 10^5$) — the number of vertices in the tree and the number of queries.

The next $n - 1$ lines of each test case contain three integers $v$, $u$, $w$ ($1 \le v, u \le n$, $1 \le w \le 10^9$) — the ends of some edge in the tree and its weight.

It is guaranteed that the given set of edges forms a tree.

The next $m$ lines of each test case describe the queries:

  * ^ $y$ ($1 \le y \le 10^9$) — parameter of the first type query;    * ? $v$ $x$ ($1 \le v \le n$, $1 \le x \le 10^9$) — parameters of the second type query.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$. The same is guaranteed for $m$.

Output: For each test case, output the answers to the queries of the second type.

Examples:
input:
2
3 7
1 2 1
3 1 8
^ 5
? 2 9
^ 1
? 1 10
^ 6
? 3 1
? 2 9
5 6
1 2 777
3 2 2812
4 1 16
5 3 1000000000
^ 4
? 3 123
? 5 1000000000
^ 1000000000
? 1 908070
? 2 1
output:
13 15 11 10
1000000127 2812 999756331 999999756

input:
3
8 4
8 6 3
6 3 4
2 5 4
7 6 2
7 1 10
4 1 4
5 1 2
^ 4
^ 7
? 7 8
? 4 10
5 6
3 1 4
2 3 9
4 3 6
5 2 10
? 5 7
^ 1
^ 8
? 4 10
? 1 9
? 3 6
4 2
2 1 4
4 3 5
2 3 4
^ 13
? 1 10
output:
14 13
13 8 11 11
10

Note:

Buggy Code:
// Generated by Code Flattener.
// https://plugins.jetbrains.com/plugin/9979-idea-code-flattener

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

import static java.lang.Math.max;

public class Main {
    public static void main(String[] args) {
        Solution obj = new Solution();
        obj.invoke();
    }

    private static class Solution {
        private final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        private final static PrintWriter out = new PrintWriter(System.out);
        private StringTokenizer st = new StringTokenizer("");
        private boolean multiCase = true;

        public void invoke() {
            int t = 1;
            if (multiCase) t = nextInt();
            while (t-- > 0) {
                solve();
            }
            out.flush();
        }

        private void solve() {
            int n = nextInt();
            int m = nextInt();
            List<int[]>[] graph = buildGraph(n);
            int[] depth = new int[n];
            int[] xorDp = new int[n];
            dfs(0, 0, depth, xorDp, graph);
            TrieXOR oddTrie = new TrieXOR(30, n);
            TrieXOR evenTrie = new TrieXOR(30, n);
            for (int i = 0; i < n; i++) {
                if (depth[i] % 2 == 1) oddTrie.add(xorDp[i]);
                else evenTrie.add(xorDp[i]);
            }
            int addedXor = 0;
            while (m-- > 0) {
                char ch = nextChar();
                if (ch == '^') {
                    int y = nextInt();
                    addedXor ^= y;
                } else {
                    int v = nextInt() - 1;
                    int x = nextInt();
                    int ans = 0;
                    if (depth[v] % 2 == 1) {
                        oddTrie.delete(xorDp[v]);
                        ans = max(ans, oddTrie.findMax(x ^ xorDp[v]));
                        oddTrie.add(xorDp[v]);
                        ans = max(ans, evenTrie.findMax(x ^ xorDp[v] ^ addedXor));
                    } else {
                        evenTrie.delete(xorDp[v]);
                        ans = max(ans, evenTrie.findMax(x ^ xorDp[v]));
                        evenTrie.add(xorDp[v]);
                        ans = max(ans, oddTrie.findMax(x ^ xorDp[v] ^ addedXor));
                    }
                    print(ans);
                }
            }
            println();
        }

        private void dfs(int node, int parent, int[] depth, int[] xorDp, List<int[]>[] graph) {
            for (int[] adjNode : graph[node]) {
                int child = adjNode[0], wt = adjNode[1];
                if (child == parent) continue;
                depth[child] = depth[node] + 1;
                xorDp[child] = xorDp[node] ^ wt;
                dfs(child, node, depth, xorDp, graph);
            }
        }

        private List<int[]>[] buildGraph(int n) {
            List<int[]>[] graph = new List[n];
            for (int i = 0; i < n; i++) {
                graph[i] = new ArrayList<>();
            }
            for (int i = 1; i < n; i++) {
                int u = nextInt() - 1;
                int v = nextInt() - 1;
                int w = nextInt();
                graph[u].add(new int[]{v, w});
                graph[v].add(new int[]{u, w});
            }
            return graph;
        }

        public String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public void print(Object... str) {
            for (Object s : str)
                out.print(s + " ");
        }

        public void println(Object... str) {
            for (Object s : str)
                print(s);
            out.println();
        }
    }

    private static class TrieXOR {
        int l, c;
        int[][] node;
        int[] cnt;

        public TrieXOR(int l, int maxMembers) {
            this.l = l;
            this.c = 0;
            this.node = new int[(l + 2) * maxMembers + 3][2];
            this.cnt = new int[(l + 2) * maxMembers + 3];
        }

        public void add(int x) {
            int cur = 0;
            for (int i = l; i >= 0; --i) {
                boolean hasBit = ((1 << i) & x) != 0;
                if (node[cur][hasBit ? 1 : 0] == 0) {
                    node[cur][hasBit ? 1 : 0] = ++c;
                }
                cur = node[cur][hasBit ? 1 : 0];
                cnt[cur]++;
            }
        }

        public void delete(int x) {
            int cur = 0;
            for (int i = l; i >= 0; --i) {
                boolean hasBit = ((1 << i) & x) != 0;
                if (node[cur][hasBit ? 1 : 0] == 0) {
                    node[cur][hasBit ? 1 : 0] = ++c;
                }
                cur = node[cur][hasBit ? 1 : 0];
                cnt[cur]--;
            }
        }

        public int findMax(int x) {
            int cur = 0;
            int ans = 0;
            for (int i = l; i >= 0; --i) {
                boolean hasBit = ((1 << i) & x) != 0;
                if (node[cur][hasBit ? 0 : 1] != 0 && cnt[node[cur][hasBit ? 0 : 1]] > 0) {
                    ans += 1 << i;
                    cur = node[cur][hasBit ? 0 : 1];
                } else {
                    cur = node[cur][hasBit ? 1 : 0];
                }
            }
            return ans;
        }
    }
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
To generate a challenging test input that exposes the bug in the provided code, we need to consider edge cases and scenarios that might cause the code to fail. Here are the steps to think through this process:

1. **Understand the Bug**: The provided code seems to have a potential issue with the way it handles the XOR operations and the Trie data structure. Specifically, the code might not correctly handle the deletion and addition of values in the Trie, especially when the XOR value is updated multiple times.

2. **Edge Cases**:
   - **Single Node Trees**: Trees with a small number of nodes.
   - **Large XOR Values**: Queries with very large XOR values.
   - **Multiple Queries of the Same Type**: Multiple queries of the same type (e.g., multiple XOR queries) to see if the state is maintained correctly.
   - **Special Edge Weights**: Edge weights that might cause unexpected behavior in the XOR operations.

3. **Generate a Test Input**:
   - **Tree Structure**: Create a simple tree with a few nodes.
   - **Queries**: Include a mix of XOR and query operations to test the state transitions.

Given these considerations, here is a small-scale test input that should help expose potential issues:

```plaintext
1
4 6
1 2 3
2 3 4
3 4 5
^ 1
? 1 2
^ 2
? 2 3
^ 3
? 4 4
```

### Explanation:
- **Tree Structure**:
  - Node 1 is connected to Node 2 with weight 3.
  - Node 2 is connected to Node 3 with weight 4.
  - Node 3 is connected to Node 4 with weight 5.

- **Queries**:
  - `^ 1`: XOR all edge weights with 1.
  - `? 1 2`: Query for the maximum XOR value for vertex 1 with weight 2.
  - `^ 2`: XOR all edge weights with 2.
  - `? 2 3`: Query for the maximum XOR value for vertex 2 with weight 3.
  - `^ 3`: XOR all edge weights with 3.
  - `? 4 4`: Query for the maximum XOR value for vertex 4 with weight 4.

This input is designed to test the code's ability to handle multiple XOR operations and queries, ensuring that the state of the Trie and the XOR values are correctly maintained and updated.


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Yasya and the Mysterious Tree
time_limit_ms: 2500
memory_limit_mb: 512
Description: Yasya was walking in the forest and accidentally found a tree with $n$ vertices. A tree is a connected undirected graph with no cycles.

Next to the tree, the girl found an ancient manuscript with $m$ queries written on it. The queries can be of two types.

The first type of query is described by the integer $y$. The weight of each edge in the tree is replaced by the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of the weight of that edge and the integer $y$.

The second type is described by the vertex $v$ and the integer $x$. Yasya chooses a vertex $u$ ($1 \le u \le n$, $u \neq v$) and mentally draws a bidirectional edge of weight $x$ from $v$ to $u$ in the tree.

Then Yasya finds a simple cycle in the resulting graph and calculates the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of all the edges in it. She wants to choose a vertex $u$ such that the calculated value is maximum. This calculated value will be the answer to the query. It can be shown that such a cycle exists and is unique under the given constraints (independent of the choice of $u$). If an edge between $v$ and $u$ already existed, a simple cycle is the path $v \to u \to v$.

Note that the second type of query is performed mentally, meaning the tree does not change in any way after it.

Help Yasya answer all the queries.

Input: The first line contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

The descriptions of the test cases follow.

The first line of each test case contains two integers $n$, $m$ ($2 \le n \le 2 \cdot 10^5$, $1 \le m \le 2 \cdot 10^5$) — the number of vertices in the tree and the number of queries.

The next $n - 1$ lines of each test case contain three integers $v$, $u$, $w$ ($1 \le v, u \le n$, $1 \le w \le 10^9$) — the ends of some edge in the tree and its weight.

It is guaranteed that the given set of edges forms a tree.

The next $m$ lines of each test case describe the queries:

  * ^ $y$ ($1 \le y \le 10^9$) — parameter of the first type query;    * ? $v$ $x$ ($1 \le v \le n$, $1 \le x \le 10^9$) — parameters of the second type query.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$. The same is guaranteed for $m$.

Output: For each test case, output the answers to the queries of the second type.

Examples:
input:
2
3 7
1 2 1
3 1 8
^ 5
? 2 9
^ 1
? 1 10
^ 6
? 3 1
? 2 9
5 6
1 2 777
3 2 2812
4 1 16
5 3 1000000000
^ 4
? 3 123
? 5 1000000000
^ 1000000000
? 1 908070
? 2 1
output:
13 15 11 10
1000000127 2812 999756331 999999756

input:
3
8 4
8 6 3
6 3 4
2 5 4
7 6 2
7 1 10
4 1 4
5 1 2
^ 4
^ 7
? 7 8
? 4 10
5 6
3 1 4
2 3 9
4 3 6
5 2 10
? 5 7
^ 1
^ 8
? 4 10
? 1 9
? 3 6
4 2
2 1 4
4 3 5
2 3 4
^ 13
? 1 10
output:
14 13
13 8 11 11
10

Note:

Buggy Code:
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define int long long
// #define i128 __int128
// #define i128 int
#define all(n) n.begin(),n.end()
using namespace std;
typedef pair<int,int> PII;
const int N = 4e5+10,MOD = 998244353;
int n,m,k;
int h[N],e[N],ne[N],w[N];
int idx;
int idx1[2];
int tire[2][N][2];
int st[2][N*4];
int query(int x,int tire[N][2],int st[N],int &idx){
    int p = 0,res = 0;
    for(int i = 31;i>=0;i--){
        int k = x>>i&1;
        if(st[tire[p][k^1]]){
            res += 1ll<<i;
            p = tire[p][k^1];
        }else if(st[tire[p][k]]) p = tire[p][k];
        else return res;
    }
    return res;

}
void insert(int x,int tire[N][2],int st[N],int &idx){
    int p = 0;
    for(int i = 31;i>=0;i--){
        int k = x>>i&1;
        if(tire[p][k] == 0) {
            tire[p][k] = ++idx;
        }
        p = tire[p][k];
        st[p]++;
    }
}
void del(int x,int tire[N][2],int st[N],int &idx){
    int p = 0;
    for(int i = 31;i>=0;i--){
        int k = x>>i&1;
        st[tire[p][k]]--;
        p = tire[p][k];
    }
}
void add(int a,int b,int c){
    e[idx] = b,ne[idx] = h[a],w[idx] = c,h[a] = idx++;
}

void sove(){
    for(int i = 0;i<=idx1[0];i++) tire[0][i][0] = tire[0][i][1] = 0,st[0][i] = 0;
    for(int i = 0;i<=idx1[1];i++) tire[1][i][0] = tire[1][i][1] = 0,st[1][i] = 0;
    idx1[0] = idx1[1] = 0;
   cin>>n>>m;
   for(int i = 1;i<=n;i++) h[i] = -1;
   for(int i = 1;i<n;i++){
       int a,b,c;
       cin>>a>>b>>c;
       add(a,b,c);
       add(b,a,c);
   }
   vector<int> pre(n+1,0),dep(n+1,0);
   auto dfs = [&](auto &&dfs,int u,int p) -> void {
       insert(pre[u],tire[dep[u]],st[dep[u]],idx1[dep[u]]);
       for(int i = h[u];i!=-1;i = ne[i]){
           int k = e[i];
           if(k == p) continue;
           dep[k] = dep[u] ^ 1;
           pre[k] = pre[u] ^ w[i];
           dfs(dfs,k,u);
       }
   };
   dfs(dfs,1,1);
   int mul = 0;
   while(m--){
       char c;
       cin>>c;
       if(c == '^'){
           int x;
           cin>>x;
           mul ^= x;
       }else {
           int v,x;
           cin>>v>>x;
           int ans = pre[v]^x^(dep[v]*mul);
           del(pre[v],tire[dep[v]],st[dep[v]],idx1[dep[v]]);
           int res = max(query(ans,tire[0],st[0],idx1[0]),query(ans^mul,tire[1],st[1],idx1[1]));
           cout<<res<<" ";
           insert(pre[v],tire[dep[v]],st[dep[v]],idx1[dep[v]]);
       }
   }
   cout<<endl;

}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int t = 1;
    cin>>t;
    while(t--) sove();

    return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
2
3 3
1 2 1
3 1 8
^ 5
? 2 9
? 3 1
5 4
1 2 777
3 2 2812
4 1 16
5 3 1000000000
^ 4
? 3 123
? 5 1000000000
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Yasya and the Mysterious Tree
time_limit_ms: 2500
memory_limit_mb: 512
Description: Yasya was walking in the forest and accidentally found a tree with $n$ vertices. A tree is a connected undirected graph with no cycles.

Next to the tree, the girl found an ancient manuscript with $m$ queries written on it. The queries can be of two types.

The first type of query is described by the integer $y$. The weight of each edge in the tree is replaced by the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of the weight of that edge and the integer $y$.

The second type is described by the vertex $v$ and the integer $x$. Yasya chooses a vertex $u$ ($1 \le u \le n$, $u \neq v$) and mentally draws a bidirectional edge of weight $x$ from $v$ to $u$ in the tree.

Then Yasya finds a simple cycle in the resulting graph and calculates the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of all the edges in it. She wants to choose a vertex $u$ such that the calculated value is maximum. This calculated value will be the answer to the query. It can be shown that such a cycle exists and is unique under the given constraints (independent of the choice of $u$). If an edge between $v$ and $u$ already existed, a simple cycle is the path $v \to u \to v$.

Note that the second type of query is performed mentally, meaning the tree does not change in any way after it.

Help Yasya answer all the queries.

Input: The first line contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

The descriptions of the test cases follow.

The first line of each test case contains two integers $n$, $m$ ($2 \le n \le 2 \cdot 10^5$, $1 \le m \le 2 \cdot 10^5$) — the number of vertices in the tree and the number of queries.

The next $n - 1$ lines of each test case contain three integers $v$, $u$, $w$ ($1 \le v, u \le n$, $1 \le w \le 10^9$) — the ends of some edge in the tree and its weight.

It is guaranteed that the given set of edges forms a tree.

The next $m$ lines of each test case describe the queries:

  * ^ $y$ ($1 \le y \le 10^9$) — parameter of the first type query;    * ? $v$ $x$ ($1 \le v \le n$, $1 \le x \le 10^9$) — parameters of the second type query.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$. The same is guaranteed for $m$.

Output: For each test case, output the answers to the queries of the second type.

Examples:
input:
2
3 7
1 2 1
3 1 8
^ 5
? 2 9
^ 1
? 1 10
^ 6
? 3 1
? 2 9
5 6
1 2 777
3 2 2812
4 1 16
5 3 1000000000
^ 4
? 3 123
? 5 1000000000
^ 1000000000
? 1 908070
? 2 1
output:
13 15 11 10
1000000127 2812 999756331 999999756

input:
3
8 4
8 6 3
6 3 4
2 5 4
7 6 2
7 1 10
4 1 4
5 1 2
^ 4
^ 7
? 7 8
? 4 10
5 6
3 1 4
2 3 9
4 3 6
5 2 10
? 5 7
^ 1
^ 8
? 4 10
? 1 9
? 3 6
4 2
2 1 4
4 3 5
2 3 4
^ 13
? 1 10
output:
14 13
13 8 11 11
10

Note:

Buggy Code:
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;

#define N 200005

int T,n,m,st[N],cnt,d[N],od[N],tr1[N * 31][2],tr2[N * 31][2],n1,n2,tot,ans,c1[N],c2[N],b1[N],b2[N];

struct Edge
{
	int next,to,val;
}ed[N << 1];

int max(int x,int y) { return x > y ? x : y ; }

void add(int u,int v,int w)
{
	ed[++ cnt].next = st[u];
	ed[cnt].to = v;
	ed[cnt].val = w;
	st[u] = cnt;
	return;
}

void dfs(int x,int fa,int dep)
{
	od[x] = dep & 1;
	for (int i = st[x]; ~i ;i = ed[i].next)
	{
		int rec = ed[i].to;
		if(rec == fa) continue;
		d[rec] = d[x] ^ ed[i].val;
		dfs(rec,x,dep + 1);
	}
	return;
}

void add1(int x,int y)
{
	int now = 0;
	for (int i = 30;i >= 0;-- i)
	{
		int tmp = (x >> i) & 1;
		if(tr1[now][tmp]) now = tr1[now][tmp],++ c1[now];
		else tr1[now][tmp] = ++ n1,now = n1,c1[now] = 1;
		b1[now] = y;
	}
	return;
}

void add2(int x,int y)
{
	int now = 0;
	for (int i = 30;i >= 0;-- i)
	{
		int tmp = (x >> i) & 1;
		if(tr2[now][tmp]) now = tr2[now][tmp],++ c2[now];
		else tr2[now][tmp] = ++ n2,now = n2,c2[now] = 1;
		b2[now] = y;
	}
	return;
}

int ask1(int x,int y)
{
	int t = 0;
	int now = 0;
	for (int i = 30;i >= 0;-- i)
	{
		int tmp = (x >> i) & 1;
		if((!tr1[now][tmp ^ 1]) || (c1[tr1[now][tmp ^ 1]] == 1 && b1[tr1[now][tmp ^ 1]] == y))
			now = tr1[now][tmp];
		else t += 1 << i,now = tr1[now][tmp ^ 1];
	}
	return t;
}

int ask2(int x,int y)
{
	int t = 0;
	int now = 0;
	for (int i = 30;i >= 0;-- i)
	{
		int tmp = (x >> i) & 1;
		if((!tr2[now][tmp ^ 1]) || (c2[tr2[now][tmp ^ 1]] == 1 && b2[tr2[now][tmp ^ 1]] == y))
			now = tr2[now][tmp];
		else t += 1 << i,now = tr2[now][tmp ^ 1];
	}
	return t;
}

int main()
{
	scanf("%d",&T);
	while (T --)
	{
		scanf("%d%d",&n,&m),cnt = n1 = n2 = tot = 0;
		for (int i = 1;i <= n;++ i) st[i] = -1,d[i] = od[i] = 0;
		for (int i = 1,u,v,w;i < n;++ i) scanf("%d%d%d",&u,&v,&w),add(u,v,w),add(v,u,w);
		dfs(1,0,0);
		for (int i = 1;i <= n;++ i)
			if(od[i] & 1) add1(d[i],i);
			else add2(d[i],i);
		for (int i = 1,v,w;i <= m;++ i)
		{
			char s;
			cin >> s;
			if(s == '^') scanf("%d",&w),tot ^= w;
			else
			{
				scanf("%d%d",&v,&w),ans = 0;
				if(od[v])
				{
					ans = max(ans,ask1(d[v] ^ w,v));
					ans = max(ans,ask2(d[v] ^ w ^ tot,v));
				}
				else
				{
					ans = max(ans,ask1(d[v] ^ w ^ tot,v));
					ans = max(ans,ask2(d[v] ^ w,v));
				}
				printf("%d\n",ans);
			}
		}
		for (int i = 0;i <= n1;++ i) tr1[i][0] = tr1[i][1] = c1[i] = b1[i] = 0;
		for (int i = 0;i <= n2;++ i) tr2[i][0] = tr2[i][1] = c2[i] = b2[i] = 0;
	}
	return 0;
}

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
4 3
1 2 1
2 3 2
3 4 4
^ 3
? 2 5
? 4 7
```


**Task:**
Generate a challenging test input that exposes the bug in the buggy code of the algorithm problem:
Algorithm Problem:
Title: Yasya and the Mysterious Tree
time_limit_ms: 2500
memory_limit_mb: 512
Description: Yasya was walking in the forest and accidentally found a tree with $n$ vertices. A tree is a connected undirected graph with no cycles.

Next to the tree, the girl found an ancient manuscript with $m$ queries written on it. The queries can be of two types.

The first type of query is described by the integer $y$. The weight of each edge in the tree is replaced by the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of the weight of that edge and the integer $y$.

The second type is described by the vertex $v$ and the integer $x$. Yasya chooses a vertex $u$ ($1 \le u \le n$, $u \neq v$) and mentally draws a bidirectional edge of weight $x$ from $v$ to $u$ in the tree.

Then Yasya finds a simple cycle in the resulting graph and calculates the [bitwise exclusive OR](http://tiny.cc/xor_wiki_eng) of all the edges in it. She wants to choose a vertex $u$ such that the calculated value is maximum. This calculated value will be the answer to the query. It can be shown that such a cycle exists and is unique under the given constraints (independent of the choice of $u$). If an edge between $v$ and $u$ already existed, a simple cycle is the path $v \to u \to v$.

Note that the second type of query is performed mentally, meaning the tree does not change in any way after it.

Help Yasya answer all the queries.

Input: The first line contains an integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

The descriptions of the test cases follow.

The first line of each test case contains two integers $n$, $m$ ($2 \le n \le 2 \cdot 10^5$, $1 \le m \le 2 \cdot 10^5$) — the number of vertices in the tree and the number of queries.

The next $n - 1$ lines of each test case contain three integers $v$, $u$, $w$ ($1 \le v, u \le n$, $1 \le w \le 10^9$) — the ends of some edge in the tree and its weight.

It is guaranteed that the given set of edges forms a tree.

The next $m$ lines of each test case describe the queries:

  * ^ $y$ ($1 \le y \le 10^9$) — parameter of the first type query;    * ? $v$ $x$ ($1 \le v \le n$, $1 \le x \le 10^9$) — parameters of the second type query.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$. The same is guaranteed for $m$.

Output: For each test case, output the answers to the queries of the second type.

Examples:
input:
2
3 7
1 2 1
3 1 8
^ 5
? 2 9
^ 1
? 1 10
^ 6
? 3 1
? 2 9
5 6
1 2 777
3 2 2812
4 1 16
5 3 1000000000
^ 4
? 3 123
? 5 1000000000
^ 1000000000
? 1 908070
? 2 1
output:
13 15 11 10
1000000127 2812 999756331 999999756

input:
3
8 4
8 6 3
6 3 4
2 5 4
7 6 2
7 1 10
4 1 4
5 1 2
^ 4
^ 7
? 7 8
? 4 10
5 6
3 1 4
2 3 9
4 3 6
5 2 10
? 5 7
^ 1
^ 8
? 4 10
? 1 9
? 3 6
4 2
2 1 4
4 3 5
2 3 4
^ 13
? 1 10
output:
14 13
13 8 11 11
10

Note:

Buggy Code:
import sys
input = sys.stdin.readline

def change(x):
    A=[]
    for i in range(30,-1,-1):
        if x & (1<<i) != 0:
            A.append(1)
        else:
            A.append(0)
    return A

def conv(x):
    score=0
    for i in range(31):
        if x[i]==1:
            score+=(1<<(30-i))
    return score

t=int(input())
for tests in range(t):
    n,m=map(int,input().split())

    E=[[] for i in range(n)]

    for i in range(n-1):
        x,y,w=map(int,input().split())
        x-=1
        y-=1
        E[x].append((y,w))
        E[y].append((x,w))

    DP=[-1]*n
    DP2=[-1]*n
    Q=[0]
    DP[0]=0
    DP2[0]=0
    while Q:
        x=Q.pop()

        for to,w in E[x]:
            if DP[to]==-1:
                DP[to]=DP[x]^w
                DP2[to]=DP2[x]^1
                Q.append(to)

    #print(DP,DP2)

    # Trie木

    Next_node_id=[[-1]*2]
    Parent_id=[-1] # 親ノード
    Depth=[0] # Trieのノードの深さ
    Count=[0] # Trieのノードの重複度

    Nodes_id=1 # 以下、標準入力で与えられたN個の文字列を追加する実装

    Next_node_id2=[[-1]*2]
    Parent_id2=[-1] # 親ノード
    Depth2=[0] # Trieのノードの深さ
    Count2=[0] # Trieのノードの重複度

    Nodes_id2=1 # 以下、標準入力で与えられたN個の文字列を追加する実装

    NODEID=[-1]*n

    for i in range(n):
        if DP2[i]==0:
            S=change(DP[i])
            L=len(S)

            NOW=0
            for s in S:
                NEXT=s

                if Next_node_id[NOW][NEXT]==-1: # Nodeを追加する場合
                    Next_node_id[NOW][NEXT]=Nodes_id

                    Next_node_id.append([-1]*2)
                    Parent_id.append(NOW)
                    Depth.append(Depth[NOW]+1)
                    Count.append(0)

                    NOW=Nodes_id
                    Nodes_id+=1

                else: # 追加しない場合
                    NOW=Next_node_id[NOW][NEXT]

            NODEID[i]=NOW

            while NOW!=-1:
                Count[NOW]+=1
                NOW=Parent_id[NOW]

        else:
            S=change(DP[i])
            L=len(S)

            NOW=0
            for s in S:
                NEXT=s

                if Next_node_id2[NOW][NEXT]==-1: # Nodeを追加する場合
                    Next_node_id2[NOW][NEXT]=Nodes_id2

                    Next_node_id2.append([-1]*2)
                    Parent_id2.append(NOW)
                    Depth2.append(Depth2[NOW]+1)
                    Count2.append(0)

                    NOW=Nodes_id2
                    Nodes_id2+=1

                else: # 追加しない場合
                    NOW=Next_node_id2[NOW][NEXT]

            NODEID[i]=NOW

            while NOW!=-1:
                Count2[NOW]+=1
                NOW=Parent_id2[NOW]

    ANS=[]
    nowbit=0

    for queries in range(m):
        Q=input().split()

        if Q[0]=="^":
            nowbit^=int(Q[1])
        else:
            x=int(Q[1])-1
            w=int(Q[2])

            #print("今のクエリ",x,w,nowbit)

            score=change(((1<<31)-1)^w^DP[x])
            score2=change(((1<<31)-1)^w^nowbit^DP[x])

            if DP2[x]==0:
                NOW=NODEID[x]

                while NOW!=-1:
                    Count[NOW]-=1
                    NOW=Parent_id[NOW]

                NOW=0
                KI=[]
                for s in score:
                    NEXT=s

                    if Next_node_id[NOW][NEXT]!=-1 and Count[Next_node_id[NOW][NEXT]]>0:
                        KI.append(NEXT)
                        NOW=Next_node_id[NOW][NEXT]
                    else:
                        KI.append(NEXT^1)
                        NOW=Next_node_id[NOW][NEXT^1]

                NOW=0
                KI2=[]
                for s in score2:
                    NEXT=s

                    if Next_node_id2[NOW][NEXT]!=-1 and Count2[Next_node_id2[NOW][NEXT]]>0:
                        KI2.append(NEXT)
                        NOW=Next_node_id2[NOW][NEXT]
                    else:
                        KI2.append(NEXT^1)
                        NOW=Next_node_id2[NOW][NEXT^1]

                #print("!",score,score2,KI,KI2)
                KIX=conv(KI)
                KIX2=conv(KI2)

                #print(KIX^w^DP[x],KIX2^w^DP[x],KIX^w^nowbit^DP[x],KIX2^w^nowbit^DP[x])
                ANS.append(max(KIX^w^DP[x],KIX2^w^nowbit^DP[x]))

                NOW=NODEID[x]

                while NOW!=-1:
                    Count[NOW]+=1
                    NOW=Parent_id[NOW]

            else:
                NOW=NODEID[x]

                while NOW!=-1:
                    Count2[NOW]-=1
                    NOW=Parent_id2[NOW]

                NOW=0
                KI=[]
                for s in score2:
                    NEXT=s

                    if Next_node_id[NOW][NEXT]!=-1 and Count[Next_node_id[NOW][NEXT]]>0:
                        KI.append(NEXT)
                        NOW=Next_node_id[NOW][NEXT]
                    else:
                        KI.append(NEXT^1)
                        NOW=Next_node_id[NOW][NEXT^1]

                NOW=0
                KI2=[]
                for s in score:
                    NEXT=s

                    if Next_node_id2[NOW][NEXT]!=-1 and Count2[Next_node_id2[NOW][NEXT]]>0:
                        KI2.append(NEXT)
                        NOW=Next_node_id2[NOW][NEXT]
                    else:
                        KI2.append(NEXT^1)
                        NOW=Next_node_id2[NOW][NEXT^1]

                #print("?",score,score2,KI,KI2)
                KIX=conv(KI)
                KIX2=conv(KI2)

                #print(KIX^w^DP[x],KIX2^w^DP[x],KIX^w^nowbit^DP[x],KIX2^w^nowbit^DP[x])
                ANS.append(max(KIX^w^nowbit^DP[x],KIX2^w^DP[x]))

                NOW=NODEID[x]

                while NOW!=-1:
                    Count2[NOW]+=1
                    NOW=Parent_id2[NOW]

    print(*ANS)

**Instructions:**
- Focus on edge cases or scenarios that maximize the failure probability in faulty solutions.
- Due to the output length limit, you should generate a **small-scale** test input that is **complete and valid**.
- Output the test input directly, not code to generate it.

**Output format:**
```plaintext
{test input}
```

Think step by step.

Response:
```plaintext
1
4 3
1 2 1
2 3 2
3 4 4
^ 3
? 1 5
? 4 6
```