#P3613. 【深基15.例2】寄包柜

【深基15.例2】寄包柜

Problem Description

There are n(1n105)n(1\le n\le10^5) parcel lockers in a supermarket. Each locker has a different number of compartments. The ii-th locker has ai(0ai105)a_i(0\le a_i\le10^5) compartments, but we do not know the values of aia_i. For each locker, the compartments are numbered from 1 to aia_i. Now there are q(1q105)q(1 \le q\le10^5) operations:

  • 1 i j k: Put item k(0k109)k(0\le k\le 10^9) into compartment jj of locker ii. When k=0k=0, it means clearing that compartment.
  • 2 i j: Query what item is in compartment jj of locker ii. It is guaranteed that the queried locker has had items stored in it.

It is known that the total number of compartments in the supermarket will not exceed 10710^7. The values aia_i are fixed but unknown, and it is guaranteed that aia_i is at least the maximum compartment index ever used in a store-item request for that locker. Of course, it is also possible that some lockers do not have even a single compartment.

Input Format

The first line contains 2 integers nn and qq, the number of parcel lockers and the number of queries.

The next qq lines each contain several integers, representing one operation.

Output Format

For each query operation, output the answer, one per line.

5 4
1 3 10000 118014
1 1 1 1
2 3 10000
2 1 1
118014
1

Hint

upd 2022.7.26\text{upd 2022.7.26}: A new set of hack testdata has been added.

Translated by ChatGPT 5