Toggle Bulbs

medium
You are given n bulbs, numbered from 1 to n. Initially all the bulbs are turned off.
You have to perform 2 types of operations:-

1. Toggle all bulds numbered between A to B.Here toggle mean turn on bulbs to off and off bulbs to on.This is represented by 1 A B.
2. Count how many bulbs numbered between A to B are on.This is represented by 2 A B.

Input Format

First line contains two integers n and q. Following q lines contains queries of format either 1 A B or 2 A B.

Output Format

Print count of bulbs for query type 2 A B.

Constraints

1. 1 <= n <= 10^5
2. 1 <= q <= 10^5
3. 1 <= A <= B <= n

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
4 7
2 1 4
1 2 3
2 1 2
2 1 1
1 1 4
2 1 4 
2 4 4
Output
0
1
0
2
1
Previous
2d Segment Tree
Next
Prime Divide

Related Questions