# Lights SOLUTION September Circuits ’20

Page Contents

### Lights SOLUTION September Circuits ’20

There are N lights, numbered from 1 to N. At first every one of them are turned off. We will think about M days. We speak to the condition of every day as a line of length N, whose character is 1 if the light on that day was turned on, and 0 in any case. Every the very first moment of the accompanying things will occur:

1 L R: All the lights numbered from L to R are flipped, i.e, lights are killed in the event that they were turned on and the other way around.

2 A B L R: For each light from L to R, rely on how long from everyday, this light was on (Let it be x). Print the number of lights (from L to R) are there which were turned on an all out odd number of days (i.e, ). Likewise, print the base id of light (from L to R), which was turned on a complete odd number of days (considering from Ath day to Bth day). Condition of lights doesn’t change in this kind of question.

3 : Considering conditions of the apparent multitude of days till now, which day had the lexicographically biggest state (if various, print the soonest day). Condition of lights doesn’t change in this kind of inquiry.

Info Format

First line contains a solitary number (), the quantity of experiments.

The principal line of each test contains two numbers, () and (), where means the quantity of ligths and indicates the quantity of days.

Every one of the following lines begins with a number () which speaks to the sort of question. On the off chance that is , it will be trailed by two numbers and (). In the event that is , it will be trailed by four numbers , and (, ), where X is the current day number. On the off chance that is , it will be the main whole number in that line.

Yield Format

For all the inquiries that are of type and type , print the necessary answer. In second sort of inquiry if no light among L and R was turned on a complete odd number of days (between Ath day and Bth day), print “0” (without cites). Likewise, in third sort of question, if there is no adjustment in the condition of lights (from 0th day), print “0” (without cites).

Test INPUT

8 7

1 3 6

2 1 4

2 1 8

1 5 6

2 1 5 1 8

2 1 6 1 8

5 2

2 1 5

Test OUTPUT

2 3

4 3

4 3

2 5

Clarification

In the primary experiment of the given example:

State on 0th day: 00000000 (Initial State)

State on first day: 00111100

State on second day: 00111100 (stays same). On first day, among lights from 1 to 4, third and fourth lights (absolute 2 lights) were turned on an all out odd number (1) of days. Additionally, least id of light (which was turned on a complete odd number of days) is 3. So “2 3” ought to be printed.

State on third day: 00111100 (stays same). On first day, among lights from 1 to 8, third, fourth, fifth and sixth lights (absolute 4 lights) were turned on an all out odd number (1) of days. Additionally, least id of light is 3. So “4 3” ought to be printed.

State on fourth day: 00110000

State on fifth day: 00110000 (stays same). Thinking about initial 5 days, third and fourth lights were turned on 5 days. Likewise, fifth and sixth lights were turned on 3 days. In this way, third, fourth, fifth and sixth lights (complete 4 lights) were turned on an absolute odd number of days. Additionally, least id of light is 3. So “4 3” ought to be printed.

State on sixth day: 00110000 (stays same). Thinking about initial 6 days, third and fourth lights were turned on 6 days. fifth and sixth lights were turned on 3 days. In this way, fifth and sixth lights (complete 2 lights) were turned on an all out odd number of days. Likewise, least id of light is 5. So “2 5” ought to be printed.

State on seventh day: 00110000 (stays same). On first day, state was lexicographically biggest. So “1” ought to be printed.

In the subsequent experiment of the given example:

State on 0th day: 00000

State on first day: 00000 (stays same). Since no light from 1 to 5 was turned on an absolute odd number of days on first day, “0” ought to be printed.

State on second day: 00000 (stays same). Since there is no adjustment in state, “0” ought to be printed.