cho.sh
Notes
Loading...

Switches

Time limit

1s

Memory limit

128 MB

Problem

There are N switches numbered from 1 to N in Jungyu's house. Initially, every switch is off.

You must process two kinds of operations.

  • 0 S_i T_i: flip every switch from switch S_i through switch T_i. An on switch becomes off, and an off switch becomes on.
  • 1 S_i T_i: count how many switches are currently on from switch S_i through switch T_i.

Process all operations in the order they are given.

Input

The first line contains the number of switches N (2 ≤ N ≤ 100,000) and the number of operations M (1 ≤ M ≤ 100,000).

Each of the next M lines contains three integers O, S_i, and T_i describing one operation. If O is 0, flip the state of every switch in the range. If O is 1, answer how many switches are on in the range.

Output

For each operation with O = 1, print the number of switches that are on in the requested range, one answer per line.