cho.sh
Notes
Loading...

Switches On and Off

Time limit

2s

Memory limit

128 MB

Problem

There is a row of switches numbered consecutively from 1. Each switch is either on or off. The table below shows the states of 8 switches. 1 means the switch is on, and 0 means it is off.

Several students are chosen, and each student receives one natural number between 1 and the number of switches, inclusive. Each student changes switch states according to their gender and the number they received.

A male student changes every switch whose number is a multiple of the number he received. That is, an on switch becomes off, and an off switch becomes on. If the switches are in the state shown in Figure 1 and a male student receives 3, he changes switches 3 and 6, producing the state in Figure 2.

Switch number①②③④⑤⑥⑦⑧
Switch state01010001

Figure 1

A female student finds the largest interval centered on the switch with the same number as the number she received, such that the switch states are symmetric to the left and right of the center. She changes every switch in that interval. The number of switches in the interval is always odd.

For example, in Figure 2, if a female student receives 3, switches 2 and 4 have the same state, and switches 1 and 5 also have the same state. Therefore she changes all switches from 1 through 5, producing Figure 3. If a female student receives 4 in Figure 2, switches 3 and 5 have different states, so she changes only switch 4.

Switch number①②③④⑤⑥⑦⑧
Switch state01110101

Figure 2

Switch number①②③④⑤⑥⑦⑧
Switch state10001101

Figure 3

Given the initial states of the switches and each student's gender and received number, apply the students' operations in input order and print the final states of all switches.

Input

The first line contains the number of switches. It is a positive integer not greater than 100.

The second line contains the state of each switch, in order. An on switch is written as 1, an off switch as 0, with one space between adjacent states.

The third line contains the number of students. It is a positive integer not greater than 100.

Each line from the fourth line to the end contains one student's gender and the number that student received. A male student is written as 1, and a female student as 2. The received number is a positive integer not greater than the number of switches. The gender and the received number are separated by one space.

Output

Print the switch states from switch 1 through the last switch, with at most 20 states on each line. For example, if there is a switch 21, its state is printed at the beginning of the second line.

Print an on switch as 1 and an off switch as 0, with one space between adjacent states.