| VI UnBalloon Contest Mirror |
|---|
| Finished |
Frank and his friends are playing a game at the little gas station. The game has a list of $$$n$$$ distinct languages $$$a_1, a_2, \ldots , a_n$$$. Each language is represented by a number from $$$1$$$ to $$$n$$$ and appears only once. Frank does not trust the competitive programming skills of Brazilians, so he wants you to answer $$$q$$$ queries. Each query contains two integers $$$l$$$ and $$$r$$$, and you need to tell Frank if the sublist $$$a_l, a_{l+1}, \ldots , a_r$$$ is a good drink. Since Frank only speaks Polish, respond with "TAK" if the list is a good drink and "NIE" otherwise.
A list of size $$$m$$$ is a good drink if it is a permutation, that is, it contains all the numbers from $$$1$$$ to $$$m$$$ exactly once.
The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \leq n, q \leq 10^5$$$), the size of the list and the number of queries, respectively.
The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots , a_n$$$ ($$$1 \leq a_i \leq n$$$), representing the elements of the list. It is guaranteed that the list is a permutation.
The next $$$q$$$ lines contain two integers $$$l$$$ and $$$r$$$ ($$$1 \leq l \leq r \leq n$$$), representing the queries.
For each query, print a line with the word "TAK" if the sublist $$$a_l, a_{l+1}, \ldots , a_r$$$ forms a permutation, or "NIE" otherwise.
4 31 2 3 41 22 31 4
TAK NIE TAK
5 44 1 2 3 52 31 32 41 4
TAK NIE TAK TAK
1 111 1
TAK
| Name |
|---|


