Jeel and Ashish play a game on an $n \times m$ matrix. The rows are numbered $1$ to $n$ from top to bottom and the columns are numbered $1$ to $m$ from left to right. They play turn by turn. Ashish goes first.

Initially, each cell of the matrix contains a non-negative integer. Each turn, a player must perform all of the following actions in order.

Choose a starting cell $(r_1, c_1)$ with non-zero value.

Choose a finishing cell $(r_2, c_2)$ such that $r_1 \leq r_2$ and $c_1 \leq c_2$.

Decrease the value of the starting cell by some positive non-zero integer.

Pick any of the shortest paths between the two cells and either increase, decrease or leave the values of cells on this path unchanged. Note that:

a shortest path is one that passes through the least number of cells;

all cells on this path excluding the starting cell, but the finishing cell may be modified;

the resulting value of each cell must be a non-negative integer;

the cells are modified independently and not necessarily by the same value.

If the starting and ending cells are the same, then as per the rules, the value of the cell is decreased. No other operations are performed.

The game ends when all the values become zero. The player who is unable to make a move loses. It can be shown that the game will end in a finite number of moves if both players play optimally.

Given the initial matrix, if both players play optimally, can you predict who will win?


-----Input-----

The first line contains a single integer $t$ ($1 \leq t \leq 10$) — the number of test cases. The description of each test case is as follows.

The first line of each test case contains two integers $n$ and $m$ ($1 \leq n, m \leq 100$) — the dimensions of the matrix.

The next $n$ lines contain $m$ space separated integers $a_{i,j}$ ($0 \leq a_{i,j} \leq 10^6$) — the values of each cell of the matrix.


-----Output-----

For each test case, if Ashish wins the game, print "Ashish", otherwise print "Jeel" (without the quotes).


-----Examples-----

Input
4
1 1
0
1 3
0 0 5
2 2
0 1
1 0
3 3
1 2 3
4 5 6
7 8 9
Output
Jeel
Ashish
Jeel
Ashish


-----Note-----

In the first test case, the only cell of the matrix is 0. There are no moves Ashish can make. Jeel is the winner.

In the second test case, Ashish can choose $(r_1, c_1) = (r_2, c_2) = (1,3)$ and reduce the cell to $0$, leaving $[0, 0, 0]$. Jeel cannot perform any moves. Ashish wins.

Difficulty: VERY_HARD
Tags: Game theory

Constructive algorithms

Starter code:

Solutions:
def solve_case():
	(n, m) = [int(x) for x in input().split()]
	a = [[int(x) for x in input().split()] for x in range(n)]
	xr = [0] * (n + m)
	for i in range(n):
		for j in range(m):
			xr[i + j] ^= a[i][j]
	return sum(xr) > 0
for _ in range(int(input())):
	print(['Jeel', 'Ashish'][solve_case()])


T = int(input())
for t in range(T):
	(n, m) = list(map(int, input().split()))
	min_has = 1000000000.0
	min_xor = 0
	a = [list(map(int, input().split())) for i in range(n)]
	flag = False
	for s in range(n + m - 1):
		xor = 0
		for i in range(n):
			j = s - i
			if j < 0 or j >= m:
				continue
			if a[i][j] == 0:
				continue
			has = True
			xor ^= a[i][j]
		if xor != 0:
			flag = True
			break
	print('Ashish' if flag else 'Jeel')


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def solve():
	(n, m) = map(int, inputi().split())
	aa = [[int(a) for a in inputi().split()] for _ in range(n)]
	xor = [0] * (n + m)
	for i in range(n):
		for j in range(m):
			xor[i + j] ^= aa[i][j]
	if any((x != 0 for x in xor)):
		print('Ashish')
	else:
		print('Jeel')

def main():
	t = int(inputi())
	for _ in range(t):
		solve()
main()


def nullify(n, m, mat):
	xor = [0 for i in range(n + m - 1)]
	for i in range(n):
		for j in range(m):
			xor[i + j] ^= mat[i][j]
	for i in range(n + m - 1):
		if xor[i]:
			return 'Ashish'
	return 'Jeel'
t = int(input())
for i in range(t):
	mat = []
	(n, m) = map(int, input().split())
	for j in range(n):
		mat.append(list(map(int, input().split())))
	print(nullify(n, m, mat))


def solve():
	(n, m) = [int(x) for x in input().split()]
	a = []
	for i in range(n):
		v = [int(x) for x in input().split()]
		a.append(v)
	xorsums = [0] * (n + m - 1)
	for i in range(n):
		for j in range(m):
			xorsums[i + j] ^= a[i][j]
	f = 0
	for i in range(n + m - 1):
		if xorsums[i] != 0:
			f = 1
	if f == 1:
		print('Ashish')
	else:
		print('Jeel')

def main():
	t = int(input())
	for i in range(t):
		solve()
main()


from functools import reduce

def main():
	N = int(input())
	for _ in range(N):
		(r, c) = map(int, input().split())
		M = [list(map(int, input().split())) for _ in range(r)]
		L = [reduce(lambda x, y: x ^ y, (M[s - k][k] for k in range(max(s - r + 1, 0), min(s, c - 1) + 1))) for s in range(r + c - 1)]
		print('Jeel' if all((x == 0 for x in L)) else 'Ashish')
main()


from sys import stdin, stdout

def solve():
	(n, m) = list(map(int, input().split()))
	a = [[0] * m for _ in range(n)]
	for i in range(n):
		a[i] = list(map(int, input().split()))
	win = False
	for diagonal in range(n + m - 1):
		xor = 0
		for i in range(diagonal + 1):
			j = diagonal - i
			if j >= m or i >= n:
				continue
			xor = xor ^ a[i][j]
		if xor != 0:
			win = True
	if win:
		print('Ashish')
	else:
		print('Jeel')

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()
main()


def main():
	from sys import stdin
	from random import randint, choice, shuffle
	from functools import lru_cache
	input = stdin.readline
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		a = [[*map(int, input().split())] for i in range(n)]
		x = [0] * (n + m)
		for i in range(n):
			for j in range(m):
				x[i + j] ^= a[i][j]
		if sum(x) == 0:
			print('Jeel')
		else:
			print('Ashish')
main()