Arararagi has an array $$$a$$$ of length $$$n$$$ and two monkeys. The first monkey can take an index $$$i$$$ and set $$$a_i = a_i | x$$$ where $$$x$$$ is any nonnegative integer in one step. The second monkey can take an index $$$i$$$ and set $$$a_i = a_i \& x$$$ where $$$x$$$ is any nonnegative integer in one step. Remember $$$|$$$ is bitwise OR and $$$\&$$$ is bitwise AND.
Parallegi likes arrays when the bitwise AND of all its elements is equal to the bitwise OR of all its elements. Claragi will make two copies of his array and hand one to each monkey. He will ask each monkey to turn his array into one he likes by having them repeatedly apply their operation. Rararagi likes competition and will reward the monkey that uses fewer operations with a piece of candy (but in the case of a tie he will eat the candy and both monkeys will be sad). Help Doalagi predict which monkey will win.
The first line of input contains a single integer $$$T$$$ denoting the number of test cases $$$(1 \leq T \leq 10^4)$$$.
Each test case consists of two lines.
The first line contains a single integer $$$n$$$ $$$(1 \leq n \leq 10^5)$$$ denoting the length of $$$a$$$.
The following line contains $$$n$$$ spaced integers, the $$$i$$$'th of which being $$$a_i$$$ $$$(0 \leq a_i \leq 10^9)$$$.
It is guaranteed that the sum of $$$n$$$ across all test cases is at most $$$2 \cdot 10^5$$$.
—
Tests in subtasks are numbered from $$$1 \dots 10$$$ with samples skipped. Each test is worth $$$\frac{100}{10} = 10$$$ points.
Tests $$$1 - 5$$$ satisfy $$$0 \leq a_i \lt 4$$$.
The remaining tests do not satisfy any additional constraints.
For each test case, output "or" if the first monkey wins, "and" if the second monkey wins, or "sad" if they tie.
640 1 2 350 1 2 3 443 3 6 651 3 5 7 431 1 343366 1234 0 0
sad and sad or and and
In the first test case, the first monkey will take $$$3$$$ steps and the second monkey will also take $$$3$$$ steps.
In the second test case, the first monkey will take $$$5$$$ steps while the second monkey takes $$$4$$$ steps.
In the fourth test case, the first monkey will take $$$4$$$ steps while the second monkey takes $$$5$$$ steps.
—
Problem Idea: yash belani
Problem Preparation: 3366
Occurrences: Novice 2