szceas

Time limit: 0.42s Memory limit: 64MB Input: Output:

Suppose we have an array AA of NN integers, indexed from 1 to NN, and two positions ii and jj, such that 1≤i<j≤N1 \leq i < j \leq N. We call the array AA almost sorted if, when aia_i swaps its value with aja_j, the array AA becomes strictly increasing.

Task

Given the number NN and the elements of the array AA, determine if the given array is almost sorted.

Input Data

The first line contains the number TT, representing the number of tests.
In the next 2∗T2 * T lines, the TT tests are provided in the following format: the first line contains a natural number NN, and the second line contains NN integers, the elements of the array AA. The numbers on the same line are separated by a space.

Output Data

Print TT lines, the answers to the TT queries. Each line will contain a single word, either “DA”“DA” or “NU”“NU”, representing the answer to the question “Is the array AA almost sorted?”.

Constraints and Clarifications

  • 1≤N≤100 0001 \leq N \leq 100 \ 000;
  • 1≤1 \leq The sum of all numbers N≤5 000 000N \leq 5 \ 000 \ 000;
  • 1≤T≤100 0001 \leq T \leq 100 \ 000;
  • The numbers are distinct from each other;
  • 1≤ai≤1 000 000 000, i∈1,2,...,n1 \leq a_i \leq 1 \ 000 \ 000 \ 000, \ i ∈ {1, 2, ..., n}.
# Points Constraints
1 20 T≤5T \leq 5 and N≤100N \leq 100
2 20 T≤50T \leq 50 and N≤1000N \leq 1000
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 AA becomes:
1 3 5 7 91 \ 3 \ 5 \ 7 \ 9, which is a sorted array.
In the second test, the array is already sorted. Thus, it is not almost sorted.

Log in or sign up to be able to send submissions!