A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a _{ i} < a _{ j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), (4, 3).
You are given a permutation a of size n and m queries to it. Each query is represented by two indices l and r denoting that you have to reverse the segment [l, r] of the permutation. For example, if a = [1, 2, 3, 4] and a query l = 2, r = 4 is applied, then the resulting permutation is [1, 4, 3, 2].
After each query you have to determine whether the number of inversions is odd or even.
The first line contains one integer n (1 ≤ n ≤ 1500) — the size of the permutation.
The second line contains n integers a _{1}, a _{2}, ..., a _{ n} (1 ≤ a _{ i} ≤ n) — the elements of the permutation. These integers are pairwise distinct.
The third line contains one integer m (1 ≤ m ≤ 2·10^{5}) — the number of queries to process.
Then m lines follow, i-th line containing two integers l _{ i}, r _{ i} (1 ≤ l _{ i} ≤ r _{ i} ≤ n) denoting that i-th query is to reverse a segment [l _{ i}, r _{ i}] of the permutation. All queries are performed one after another.
Print m lines. i-th of them must be equal to odd if the number of inversions in the permutation after i-th query is odd, and even otherwise.
3
1 2 3
2
1 2
2 3
odd
even
4
1 2 4 3
4
1 1
1 4
1 4
2 3
odd
odd
odd
even
The first example:
The second example:
Name |
---|