P9833 [HackerEarth] dead mans chest
普及
题目描述

Captain Jack Sparrow and Davy Jones are having a furious sword fight to gain the key to the chest containing Davy Jones' heart. Jack wants to kill Davy Jones and live forever as the captain of The Flying Dutchman. On the other hand, Davy Jones wants to save himself from death.

A string is hanging between them. With each strike of a sword, they can strike down any one character from the string. If at any point of time before striking down a character, either of them is able to make a palindrome from the characters of the string (any anagram of the string) , he can strike down the entire string in one shot and defeat his opponent. It is known that Jack gets the first chance to strike and strikes are made alternatively by both of them.

Given the string that is hanging between them, determine who wins the fight provided that both fight to achieve their target i.e. fight optimally.

Input

The first line of each file contains T, the number of test cases.

Each of the next T line contains a string S consisting of only lower case characters (a-z).

Output

For each test case, print in a new line the winner of the sword fight - "JACK" or
"DAVY JONES" (quotes for clarity only).

Constraints

1 ≤ T ≤ 100

1 ≤ length of string S ≤ 100000

NOTE

There is partial marking for this question.

SAMPLE INPUT
2
aba
abca

SAMPLE OUTPUT
JACK
DAVY JONES

Explanation

For 2nd test case if Jack wants to win then by playing optimally he removes 'a' from the string. Else 'aca' or 'aba' will be formed by removing 'b' or 'c' respectively, which can be cut in one go as they are palindromes by Davy Jones where he would win. So Davy Jones will be left with 'bca'. Now all are distinct characters, in which he removes any one of the three. In next turn Jack removes another character and finally Davy Jones gets only single character where he wins.

输入格式

见题面

输出格式

见题面

样例输入
2 aba abca SAMPLE
样例输出
JACK DAVY JONES