Alternating Heights

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

문제

Troy is planning to take a group photo of the students at CCO and has asked you for help.

There are KK students, numbered from 11 to KK. Troy has forgotten the students' heights but remembers that no two students have the same height.

Troy has prepared a sequence A_1,A_2,,A_NA\_1, A\_2, \ldots, A\_N representing the order of students in the group photo, from left to right. It is possible for a student to appear multiple times in AA. You aren't sure how this group photo would be taken, but you're unwilling to assume that Troy made a mistake.

Troy will ask you QQ queries of the form x y, which is a compact way of asking "Given the sequence of students, A_x,A_x+1,,A_yA\_x, A\_{x + 1}, \dots, A\_y, can their heights form an alternating sequence?" More precisely, we denote the height of the ithi^\text{th} student as h\[i]h\[i]. If there exists an assignment of heights h\[1],h\[2],,h\[K]h\[1], h\[2], \ldots, h\[K] such that h\[A_x]>h\[A_x+1]<h\[A_x+2]>h\[A_x+3]<h\[A_y]h\[A\_x] > h\[A\_{x + 1}] < h\[A\_{x + 2}] > h\[A\_{x + 3}] < \ldots h\[A\_y], answer YES; otherwise, answer NO.

Note that each of the QQ queries will be independent: that is, the assignment of heights for query ii is independent of the assignment of heights for query jj so long as iji \ne j.

입력

The first line of input will contain three space-separated integers NN, KK, and QQ.

The second line of input will contain the array A_1,A_2,,A_NA\_1, A\_2, \ldots, A\_N (1A_iK)(1 \le A\_i \le K).

The next QQ lines will each contain a query of the form of two space-separated integers xx and yy (1x<yN)(1 \le x < y \le N).

출력

Output QQ lines. On the ithi^\text{th} line, output the answer to Troy's ithi^\text{th} query. Note that the answer is either YES or NO.

힌트

For the first query, we will never have h\[1]>h\[1]h\[1] > h\[1], so the answer is no.

For the second query, one solution to h\[1]>h\[2]<h\[3]>h\[1]h\[1] > h\[2] < h\[3] > h\[1] is h\[1]=160cm,h\[2]=140cm,h\[3]=180cmh\[1] = 160cm, h\[2] = 140cm, h\[3] = 180cm. Another solution could be h\[1]=1.55m,h\[2]=1.473m,h\[3]=1.81mh\[1] = 1.55m, h\[2] = 1.473m, h\[3] = 1.81m.

For the third query, we cannot have both h\[1]>h\[2]h\[1] > h\[2] and h\[1]<h\[2]h\[1] < h\[2].