QOJ.ac

QOJ

时间限制: 10 s 内存限制: 512 MB 总分: 100

#18790. Sequence and Query 32

统计

Given a sequence $A_1, A_2, \ldots, A_N$ of length $N$. Write a program that processes the following queries:

  • 1 x v: Change $A_x$ to $v$.
  • 2 k b_1 ... b_k: If the sequence $A$ can be partitioned into intervals satisfying the following conditions, output "TAK", otherwise output "NIE".

    • Each number belongs to exactly one interval.
    • Intervals must not overlap.
    • The XOR of all numbers in each interval must be equal to one of $b_1, \ldots, b_k$.

Input

The first line contains the length $N$ of the sequence. ($1 \le N \le 100{,}000$)

The second line contains $A_1, A_2, \ldots, A_N$. ($0 \le A_i < 2^{20}$)

The third line contains the number of queries $M$. ($1 \le M$)

The next $M$ lines each describe a query. ($1 \le x \le N$, $0 \le v, b_i < 2^{20}$, $1 \le k \le 5$)

The number of type 1 queries does not exceed $400{,}000$, and the total sum of $k$ over all type 2 queries does not exceed $100{,}000$.

Output

Output the results of type 2 queries.

Examples

Input 1

5
1 2 0 3 0
10
2 1 3
2 1 0
1 3 5
2 2 6 3
1 1 8
1 2 5
1 3 3
1 4 1
1 5 1
2 3 2 4 8

Output 1

TAK
TAK
TAK
NIE

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.