P28857 [洛谷] P-哥's Buckets
提高+
题目描述

Problem Description

P-哥 currently has \( n \) buckets arranged in a row, each capable of holding an unlimited number of balls. Each ball has a fixed value.

P-哥 occasionally finds new balls and places them into a specific bucket. We denote this action as \( 1 \ k \ x \), indicating that P-哥 has found a ball with value \( x \) and placed it into bucket \( k \).

P-哥 also periodically takes out some balls from specific buckets. We denote this action as \( 2 \ l \ r \), indicating that P-哥 is taking balls from bucket \( l \) to bucket \( r \). P-哥 aims to maximize the XOR sum of the values of the balls taken out.

Note: After taking out the balls, P-哥 will return them to their original positions.

Input Format

The first line contains two integers \( n \) and \( m \), representing the number of operations P-哥 will perform and the maximum bucket number involved in the dataset, respectively.

The following \( n \) lines each contain three integers, representing an operation. The format of the operations is as described in the problem.

Output Format

For each operation of type 2, output the maximum XOR sum of the values of the balls taken out by P-哥.

Sample Input and Output

Sample Input #1

5 3
1 1 2
1 2 3
1 3 4
2 1 2
2 1 3

Sample Output #1

3
7

Sample Input #2

11 10
2 6 9
1 9 1523456696
1 1 1818963290
2 6 7
1 1 102229226
2 1 9
2 3 7
1 5 34895532
1 1 1652480680
1 1 1477666032
2 1 10

Sample Output #2

0
0
1818963290
0
1857442578

Notes

For \( 20\% \) of the data, \( n, m \leq 100 \).

For \( 40\% \) of the data, \( n, m \leq 1000 \).

Additionally, \( 20\% \) of the data has all queries with \( l = 1 \) and \( r = m \).

For \( 100\% \) of the data, \( 1 \leq n, m \leq 5 \times 10^4 \), \( 1 \leq l \leq r \leq m \), \( 1 \leq k \leq m \), \( 0 \leq x \leq 2^{31} - 1 \).

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 3 1 1 2 1 2 3 1 3 4 2 1 2 2 1 3
样例输出
3 7