intervale

Time limit: 0.4s Memory limit: 32MB Input: Output:

Cosmin and Lensu were strolling on the dangerous beaches of Egypt when they spotted a shark carrying a string s. Since Harry Potter had taught them how to communicate with animals, Cosmin and Lensu tamed the shark, making it give them the string of characters. They want to keep it, but the shark said it would take it back if they did not answer several questions posed by it.

Task

Given a string s and TT queries of the form left, rightleft, \ right, the shark asks if the letters in the sequence [left, right][left, \ right] of the string s can be rearranged to form a palindromic word.

Input data

The first line contains the natural number TT, and the second line contains the string s, representing the number of questions posed by the shark. The next TT lines contain two numbers, leftleft and rightright, representing the start and end of the sequence in question. The numbers on the same line are separated by a space.

Output data

Print TT lines, each line i (1iT)i \ (1 ≤ i ≤ T) containing a single word, DA“DA” or NU“NU”, the answer to the ii-th question posed by the shark.

Constraints and clarifications

  • The string s consists only of lowercase English letters;
  • 2S5,000,0002 \leq |S| \leq 5,000,000, where S|S| represents the length of the given string;
  • 1T1,000,0001 \leq T \leq 1,000,000;
  • 1leftrightS1 \leq left \leq right \leq |S|;
# Points Constraints
1 31 T50T \leq 50 and S105\vert S \vert \leq 10^5
2 47 T100,000T \leq 100,000 and S105\vert S \vert \leq 10^5
3 22 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
zabac
2 4
3 5

stdout

DA
NU

Explanation

The letters in the sequence [2, 4] already form a palindromic word in the given order, so the answer to the first question is DA“DA”.
The letters in the sequence [3, 5], specifically a, b, and c, cannot be rearranged to form a palindromic word. Therefore, the answer to the second question is NU“NU”.

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