#P7834. Bitwise Xor

Bitwise Xor

Bitwise Xor

Problem Description

Notice:Don't output extra spaces at the end of one line. Koishi loves bitwise xor! Satori knows that, so she decides to play a game with Koishi and her nn pets. There are nn pets standing in a row, and the ii-th of them has mim_i kinds of magic, the jj-th magic can be described as a pair of non-negative integers(xij,yij)(x_{ij},y_{ij}). If she use this magic to a non-negative integer ww, then she can turn ww into wxijw\oplus x_{ij} or wyijw\oplus y_{ij} as she wants. addtionally, the ii-th pet has her favorate integer pip_i. Satori's game consists of qq rounds. In each round, one of following two things may happan:

  1. Koishi closes her third eye, so Satori select one of her pets, and change its favorate integer.
  2. Koishi's third eye reopens, so Satori tells three non-negative integers l,r,x(1lrn)l,r,x(1\leq l\leq r\leq n). Then, pets with index from ll to rr will use the magic to the integer xx one by one(ll-th is the first and rr-th is the last), every pet \textbf{must} use \textbf{each} of her magic \textbf{exactly once}. After rr-th pet finishes her operation, integer xx will become yy at last. Every pet want the final yy to be her own favorate integer pp. so the ii-th pet will try her best to make ypiy\oplus p_i as small as possible(notice yy is the final integer) . Every pet konws any other pets' magic details, favorate integer, and l,r,xl,r,x in the current round. Suppose they are all the cleverest, what's the final integer yy? Koishi is NO.1 all over the world, so she computes the final yy easily. What about you?

Input

The first line contains one positive integer T(1T15)T(1\leq T\leq 15), representing TT test cases. In each test case, the first line contains two positive integer n,q(1n,q105)n,q(1\leq n,q\leq 10^5), number of pets and rounds. Following is information of pets. For ii-th pet, the first line contains two positive integers mi,pim_i,p_i, the number of magic the ii-th pet owns and her initial favorate integer. Following are mim_i lines. jj-th of them contains two non-negative integers xij,yijx_{ij},y_{ij}.(1mi105,0p,x,y,w<230)(1\leq \sum m_i\leq 10^5,0\leq p,x,y,w< 2^{30}) Following q(1q105)q(1\leq q\leq 10^5) lines is information of each round. The ii-th line has two possibilities. 1 x y :means pxp_x is changed to y(0y<230)y(0\leq y<2^{30}) 2 l r x: means a game with parameters l,r,x(1lrn,0y<230)l,r,x(1\leq l\leq r\leq n,0\leq y<2^{30}) begins.

Output

For each game, output a line with a non-negative integer representing the final yy at last of this game.

Sample Input

1
5 6
2 11
51 25
33 10
2 26
17 52
10 44
2 30
13 52
46 51
2 16
31 34
44 35
2 34
27 4
47 61
1 4 9
2 1 4 33
1 1 47
2 1 1 47
1 3 41
2 1 3 26

Sample Output

30
61
46

Source

2020 Multi-University Training Contest 7