링크텍스트
n = int(input())
on_or_off = list(map(int, input().split()))
list = []
student_n = int(input())
for _ in range(student_n):
gender, switch = map(int, input().split())
list.append((gender, switch))
def boy(switch):
for i in range(n):
if (i+1) % switch == 0:
if (on_or_off[i] == 1): on_or_off[i] = 0
else: on_or_off[i] = 1
return on_or_off
def girl(switch):
switch_index = switch - 1
left, right = switch_index, switch_index
if on_or_off[switch_index] == 1: on_or_off[switch_index] = 0
else: on_or_off[switch_index] = 1
while True:
left -= 1
right += 1
if left == -1 or right == n or on_or_off[left] != on_or_off[right]: break
if on_or_off[left] == 1: on_or_off[left] = 0
else: on_or_off[left] = 1
if on_or_off[right] == 1: on_or_off[right] = 0
else: on_or_off[right] = 1
return on_or_off
for i in list:
if i[0] == 1: boy(i[1])
else: girl(i[1])
print(*on_or_off, sep=' ')