Suppose we have an array of integers, indexed from 1 to , and two positions and , such that . We call the array almost sorted if, when swaps its value with , the array becomes strictly increasing.
Task
Given the number and the elements of the array , determine if the given array is almost sorted.
Input Data
The first line contains the number , representing the number of tests.
In the next lines, the tests are provided in the following format: the first line contains a natural number , and the second line contains integers, the elements of the array . The numbers on the same line are separated by a space.
Output Data
Print lines, the answers to the queries. Each line will contain a single word, either or , representing the answer to the question “Is the array almost sorted?”.
Constraints and Clarifications
- ;
- The sum of all numbers ;
- ;
- The numbers are distinct from each other;
- .
# | Points | Constraints |
---|---|---|
1 | 20 | and |
2 | 20 | and |
3 | 60 | No additional constraints |
Note
Due to the very large input data, the following instructions should be used at the beginning of the program:
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
Example
stdin
2
5
1 7 5 3 9
4
1 2 3 4
stdout
DA
NU
Explanation
For the first test, if we swap the element at position 2 with the element at position 4, the array becomes:
, which is a sorted array.
In the second test, the array is already sorted. Thus, it is not almost sorted.