#D1756. Usaneko Matrix
Usaneko Matrix
Usaneko Matrix
Rabbits and cats are competing. The rules are as follows.
First, each of the two animals wrote n2 integers on a piece of paper in a square with n rows and n columns, and drew one card at a time. Shuffle two cards and draw them one by one alternately. Each time a card is drawn, the two will mark it if the same number as the card is written on their paper. The winning condition is that the number of "a set of n numbers with a mark and is in a straight line" is equal to or greater than the number of playing cards drawn at the beginning.
Answer which of the rabbit and the cat wins up to the mth card given. However, the victory or defeat is when only one of the two cards meets the victory condition when a certain card is drawn and marked. In other cases, it is a draw. Cards may be drawn even after one of them meets the victory conditions, but this does not affect the victory or defeat.
Input
Line 1: “nuvm” (square size, number of rabbit playing cards, number of cat playing cards, number of cards drawn) 2- (N + 1) Line: n2 numbers that the rabbit writes on paper ( N + 2)-(2N + 1) Line: n2 numbers that the cat writes on paper (2N + 2)-(2N + M + 1) Line: m cards drawn 1 ≤ n ≤ 500 1 ≤ u, v ≤ 13 1 ≤ m ≤ 100 000 1 ≤ (number written) ≤ 1 000 000
The number of n2 rabbits write on paper, the number of n2 cats write on paper, and the number of m cards drawn are different.
Output
Output "USAGI" if the rabbit wins, "NEKO" if the cat wins, and "DRAW" if the tie, each in one line.
Examples
Input
3 2 2 10 1 2 3 4 5 6 7 8 9 1 2 3 6 5 4 7 8 9 11 4 7 5 10 9 2 1 3 8
Output
USAGI
Input
3 2 1 10 1 2 3 4 5 6 7 8 9 1 2 3 6 5 4 7 8 9 11 4 7 5 10 9 2 1 3 8
Output
DRAW
inputFormat
Input
Line 1: “nuvm” (square size, number of rabbit playing cards, number of cat playing cards, number of cards drawn) 2- (N + 1) Line: n2 numbers that the rabbit writes on paper ( N + 2)-(2N + 1) Line: n2 numbers that the cat writes on paper (2N + 2)-(2N + M + 1) Line: m cards drawn 1 ≤ n ≤ 500 1 ≤ u, v ≤ 13 1 ≤ m ≤ 100 000 1 ≤ (number written) ≤ 1 000 000
The number of n2 rabbits write on paper, the number of n2 cats write on paper, and the number of m cards drawn are different.
outputFormat
Output
Output "USAGI" if the rabbit wins, "NEKO" if the cat wins, and "DRAW" if the tie, each in one line.
Examples
Input
3 2 2 10 1 2 3 4 5 6 7 8 9 1 2 3 6 5 4 7 8 9 11 4 7 5 10 9 2 1 3 8
Output
USAGI
Input
3 2 1 10 1 2 3 4 5 6 7 8 9 1 2 3 6 5 4 7 8 9 11 4 7 5 10 9 2 1 3 8
Output
DRAW
样例
3 2 2 10
1 2 3
4 5 6
7 8 9
1 2 3
6 5 4
7 8 9
11
4
7
5
10
9
2
1
3
8
USAGI