CSES - Tiles
  • Time limit: 1.00 s
  • Memory limit: 512 MB

Uolevi has nn tiles each consisting of a single integer from 11 to nn. Since he likes working with ceramics, he wants to combine these tiles into a tile he thinks is more artistic. But when firing a tile, it might break if it contains too many small integers. So Uolevi sometimes wants to know how many small integers a tile contains. To prevent breaking, Uolevi might need to split a tile into two tiles, the other containing smaller and the other larger integers.

More specifically, Uolevi wants to perform three types of queries:

  • 11 ii jj: Combine tiles indexed ii and jj into a single tile with index ii. It is guaranteed that tiles with indexes ii and jj exist.
  • 22 ii jj kk Split the tile with index ii into two tiles ii and jj, such that tile ii contains the kk smallest integers from the original tile, and the other tile contains the rest. It is guaranteed that both resulting tiles will be nonempty, a tile with index ii exists, and no tile with index jj exists.
  • 33 ii xx: How many integers in tile ii are at most xx? It is guaranteed that a tile with index ii exists.

Initially every integer is in its own tile, and the index of integer ii's tile is ii.

Input

The first line contains two integers nn qq: The amount of integers and queries.
qq lines follow, each being a query of one of the three types as described above:

  • 11 ii jj
  • 22 ii jj kk
  • 33 ii xx

Output

Output the answer to every query of type 33.

Constraints

  • 1n,q41051 \leq n, q \leq 4 * 10^{5}
  • 1i,j,xn1 \leq i, j, x \leq n

Example

Input:

4 8
1 1 3
1 2 4
3 1 2
3 2 1
1 1 2
3 1 3
2 1 4 2
3 4 4

Output:

1 0 3 2