Dirigent

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

Winter school of informatics ends with a traditional dance. There are nn students who participate. Each of them has a unique label between 11 and nn.

First, conductor Krešo orders the students to form a circle such that each student holds hands with two other students.

Alenka is wondering if it is possible to break the circle by making exactly one pair of neighbouring students stop holding hands and that the newly formed sequence of students is sorted by their labels. For example, if their order is 3 4 1 2, than the circle can be broken between students with labels 4 and 1, but if their order is 2 1 4 3, than there is no way to break the circle in such way.

During the night Krešo is going to give qq instructions. In each of them, he is going to order two students to swap places. After each swap you need to help Alenka answer her question.

입력

The first line contains two integers nn and qq (1n,q300,0001 ≤ n, q ≤ 300\\,000), the number of students and the number of swaps.

The second line contains nn integers a_ia\_i (1a_in1 ≤ a\_i ≤ n), describing the initial placement of students in the circle.

In each of the next qq lines there are two integers x_ix\_i, y_iy\_i (1x_i,y_in1 ≤ x\_i , y\_i ≤ n, x_iy_ix\_i \ne y\_i), that describe Krešo’s ii-th instruction in which students with labels x_ix\_i and y_iy\_i swap places.

출력

In the ii-th of the qq lines outs put the answer to Alenka’s question after ii swaps have been carried out. If the answer is affirmative output DA, otherwise NE.

힌트

Clarification of the second example: Students in the beginning, after the first and after the second swap.