Mike and Joe are playing a game with some stones. Specifically, they have $n$ piles of stones of sizes $a_1, a_2, \ldots, a_n$. These piles are arranged in a circle.

The game goes as follows. Players take turns removing some positive number of stones from a pile in clockwise order starting from pile $1$. Formally, if a player removed stones from pile $i$ on a turn, the other player removes stones from pile $((imod n) + 1)$ on the next turn.

If a player cannot remove any stones on their turn (because the pile is empty), they lose. Mike goes first.

If Mike and Joe play optimally, who will win?


-----Input-----

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 1000$). Description of the test cases follows.

The first line of each test case contains a single integer $n$ ($1 \le n \le 50$)  — the number of piles.

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^9$)  — the size of the piles.


-----Output-----

For each test case print the winner of the game, either "Mike" or "Joe" on its own line (without quotes).


-----Examples-----

Input
2
1
37
2
100 100
Output
Mike
Joe


-----Note-----

In the first test case, Mike just takes all $37$ stones on his first turn.

In the second test case, Joe can just copy Mike's moves every time. Since Mike went first, he will hit $0$ on the first pile one move before Joe does so on the second pile.

Difficulty: EASY
Tags: Game theory

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
def circle_game():
	for _ in range(int(input())):
		a = int(input())
		b = list(map(int, input().split()))
		if a % 2 != 0:
			print('Mike')
		elif b.index(min(b)) % 2 == 0:
			print('Joe')
		else:
			print('Mike')
circle_game()


import sys

def main(a, n):
	if n % 2:
		return 'Mike'
	else:
		return 'Mike' if a.index(min(a)) % 2 else 'Joe'
res = []
num = int(sys.stdin.readline())
for i in range(num):
	n = int(sys.stdin.readline())
	a = []
	a.extend([int(i) for i in sys.stdin.readline().split(' ')])
	res.append(main(a, n))
print(*res, sep='\n')


I = input
for i in range(int(I())):
	n = int(I())
	a = [*map(int, I().split())]
	print(['Joe', 'Mike'][n & 1 or a.index(min(a)) & 1])


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	if n % 2 == 0:
		mn = min(lst)
		pos = lst.index(mn)
		if pos & 1:
			print('Mike')
		else:
			print('Joe')
	else:
		print('Mike')


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	k = min(a)
	f = a.index(k) + 1
	if n % 2 != 0:
		print('Mike')
	elif f % 2 == 0:
		print('Mike')
	else:
		print('Joe')


t = int(input())
anss = []
for _ in range(t):
	n = int(input())
	piles = list(map(int, input().split()))
	if n == 1:
		anss.append('Mike')
		continue
	if n % 2 == 0:
		mini = None
		winner = None
		for i in range(len(piles)):
			if mini is None or piles[i] < mini:
				mini = piles[i]
				if i % 2 == 0:
					winner = 'Joe'
				else:
					winner = 'Mike'
		anss.append(winner)
	else:
		anss.append('Mike')
[print(ans) for ans in anss]


t = int(input())
r = []
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n % 2 == 1:
		r.append('Mike')
	else:
		da = 0
		for i in range(2, len(a), 2):
			if a[i] < a[da]:
				da = i
		yb = 1
		for i in range(3, len(a), 2):
			if a[i] < a[yb]:
				yb = i
		if a[yb] < a[da]:
			r.append('Mike')
		elif a[yb] > a[da]:
			r.append('Joe')
		elif da < yb:
			r.append('Joe')
		else:
			r.append('Mike')
for i in range(t):
	print(r[i])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n % 2 != 0:
		print('Mike')
	else:
		i = a.index(min(a))
		if i % 2 == 0:
			print('Joe')
		else:
			print('Mike')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	turn = 0
	if n % 2 == 1:
		print('Mike')
		continue
	else:
		min_a = min(a)
		for i in range(len(a)):
			if a[i] == min_a:
				if i % 2 == 0:
					print('Joe')
					break
				else:
					print('Mike')
					break


n = int(input())
for i in range(n):
	s = int(input())
	l = list(map(int, input().split()))
	if s % 2 != 0:
		print('Mike')
	else:
		u = l.index(min(l))
		if u % 2 == 0:
			print('Joe')
		else:
			print('Mike')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n % 2 == 1:
		print('Mike')
		continue
	mm = min(a[::2])
	jm = min(a[1::2])
	if mm > jm:
		print('Mike')
	elif jm > mm:
		print('Joe')
	else:
		(mi, ji) = (None, None)
		for i in range(0, n, 2):
			if a[i] == mm:
				mi = i
				break
		for i in range(1, n, 2):
			if a[i] == jm:
				ji = i
				break
		print('Mike' if mi > ji else 'Joe')


for _ in range(int(input())):
	n = int(input())
	(*val,) = map(int, input().split())
	if n == 1:
		print('Mike')
	elif n % 2 == 0:
		print('Mike' if val.index(min(val)) % 2 == 1 else 'Joe')
	else:
		print('Mike')


T = int(input())
for _ in range(T):
	n = int(input())
	L = list(map(int, input().split()))
	if n % 2 == 1:
		print('Mike')
	else:
		m = min(L)
		x = L.index(m)
		if x % 2 == 0:
			print('Joe')
		else:
			print('Mike')


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	a = [[1000000001, -1], [1000000001, -1]]
	if n % 2 == 1:
		print('Mike')
	else:
		for i in range(n):
			if s[i] < a[i % 2][0]:
				a[i % 2][0] = s[i]
				a[i % 2][1] = i
		if a[0][0] < a[1][0]:
			print('Joe')
		elif a[0][0] > a[1][0]:
			print('Mike')
		elif a[0][1] < a[1][1]:
			print('Joe')
		else:
			print('Mike')


t = int(input())
while t:
	t -= 1
	N = int(input())
	a = [*map(int, input().split())]
	if N % 2 == 1:
		print('Mike')
		continue
	m = a.index(min(a)) % 2
	if m == 0:
		print('Joe')
	else:
		print('Mike')


def game(A, n):
	if n % 2 != 0:
		return 'Mike'
	ind = 0
	for i in range(n):
		if A[i] < A[ind]:
			ind = i
	if ind % 2 == 0:
		return 'Joe'
	else:
		return 'Mike'
tests = int(input())
for _ in range(tests):
	n = int(input())
	A = list(map(int, input().split()))
	print(game(A, n))


import math, sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
mod1 = 1000000007
mod2 = 998244353
for _ in range(I()):
	n = I()
	arr = L()
	if n == 1:
		print('Mike')
		continue
	mn = 1000000000.0 + 7
	mn = min(arr)
	pos = []
	for i in range(n):
		if arr[i] == mn:
			pos.append(i)
	if n % 2 == 0:
		if pos[0] % 2 == 0:
			print('Joe')
		else:
			print('Mike')
	else:
		print('Mike')


t = int(input())
for TC in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	if n % 2 == 1:
		print('Mike')
	else:
		m = 0
		for p in range(len(a)):
			if a[p] < a[m]:
				m = p
		if m % 2 == 0:
			print('Joe')
		else:
			print('Mike')


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	if n % 2 == 1:
		print('Mike')
	else:
		x = min(arr)
		ind = arr.index(x)
		if ind % 2 == 0:
			print('Joe')
		else:
			print('Mike')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n % 2:
		print('Mike')
	else:
		m = min(a)
		for i in range(n):
			if a[i] == m:
				k = i
				break
		if k % 2:
			print('Mike')
		else:
			print('Joe')


from os import error
import sys
input = sys.stdin.readline
DEBUG = False

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def solve():
	n = inp()
	datum = inlt()
	if n % 2 == 0:
		(_minp, p) = (10 ** 9 + 3, -1)
		for (i, v) in enumerate(datum):
			if v < _minp:
				p = i
				_minp = v
		return ['Mike', 'Joe'][(p + 1) % 2]
	return 'Mike'
q = inp()
for t in range(q):
	ans = solve()
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if n % 2 == 1:
		print('Mike')
	else:
		sa = arr[0::2]
		msa = min(sa)
		idx1 = sa.index(msa) * 2
		sb = arr[1::2]
		msb = min(sb)
		idx2 = sb.index(msb) * 2 + 1
		if msa > msb:
			print('Mike')
		elif msb > msa:
			print('Joe')
		elif idx1 < idx2:
			print('Joe')
		else:
			print('Mike')


import math
t = int(input())
while t:
	t -= 1
	h = input()
	a = int(h)
	lis = input().split()
	lis = [int(x) for x in lis]
	if a % 2 == 0:
		if lis.index(min(lis)) % 2 == 0:
			print('Joe')
		else:
			print('Mike')
		continue
	else:
		print('Mike')


t = int(input())
for test in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n % 2 == 1:
		print('Mike')
	else:
		min_index = a.index(min(a))
		if min_index % 2 == 1:
			print('Mike')
		else:
			print('Joe')


for h in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	mini = 0
	minv = 10 ** 10
	i = 0
	while i < n:
		if a[i] < minv:
			minv = a[i]
			mini = i
		i += 1
	if n % 2 == 0:
		print('Mike' if mini % 2 else 'Joe')
	else:
		print('Mike')


import sys

def solve():
	inp = sys.stdin.readline
	n = int(inp())
	a = list(map(int, inp().split()))
	if n % 2 == 0:
		z = min(a)
		for i in range(n):
			a[i] -= z
		for i in range(0, int(1000000000.0)):
			if a[i % n] == 0:
				if i % 2 == 1:
					print('Mike')
				else:
					print('Joe')
				break
			a[i % n] -= 1
	else:
		for i in range(0, int(1000000000.0)):
			if a[i % n] == 0:
				if i % 2 == 1:
					print('Mike')
				else:
					print('Joe')
				break
			a[i % n] = 0

def main():
	for i in range(int(sys.stdin.readline())):
		solve()
main()


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	if n == 1:
		return 'Mike'
	oi = ei = 0
	ov = ev = float('inf')
	if n % 2 == 0:
		for i in range(n):
			if i % 2 == 0:
				if arr[i] < ov:
					oi = i
					ov = arr[i]
			elif arr[i] < ev:
				ei = i
				ev = arr[i]
		if ov > ev:
			return 'Mike'
		elif ov < ev:
			return 'Joe'
		else:
			return 'Mike' if oi > ei else 'Joe'
	else:
		return 'Mike'
for _ in range(int(input())):
	print(solve())


for q in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	x = arr.index(min(arr))
	if n == 1:
		print('Mike')
		continue
	if x % 2 == 0 and n % 2 == 0:
		print('Joe')
	else:
		print('Mike')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if n % 2 != 0:
		print('Mike')
	else:
		mini = min(l)
		ind = l.index(mini)
		if ind % 2 == 0:
			print('Joe')
		else:
			print('Mike')


t = int(input())
for i in range(t):
	n = int(input())
	piles = list(map(int, input().split()))
	if n % 2:
		print('Mike')
	else:
		(i1, low) = (0, piles[0])
		for j in range(1, n):
			if low > piles[j]:
				low = piles[j]
				i1 = j
		if i1 % 2:
			print('Mike')
		else:
			print('Joe')


t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	if n % 2 == 1:
		print('Mike')
	else:
		le = [l[0], 0]
		lo = [l[1], 1]
		for i in range(2, n):
			if i % 2 == 0:
				if l[i] < le[0]:
					le[0] = l[i]
					le[1] = i
			elif l[i] < lo[0]:
				lo[0] = l[i]
				lo[1] = i
		if le[0] > lo[0]:
			print('Mike')
		elif lo[0] > le[0]:
			print('Joe')
		elif le[1] > lo[1]:
			print('Mike')
		else:
			print('Joe')
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	circle = [int(i) for i in input().split()]
	if n % 2 == 1:
		print('Mike')
	else:
		min_pile = 1000000001
		ans = True
		for i in range(n - 1, -1, -1):
			if circle[i] <= min_pile:
				min_pile = circle[i]
				ans = i % 2 == 0
		if ans:
			print('Joe')
		else:
			print('Mike')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	dic = {False: 'Mike', True: 'Joe'}
	periodic = n % 2
	min_heap = min(a)
	argmin_heap = a.index(min_heap)
	if periodic:
		print('Mike')
	else:
		whose_turn = argmin_heap % 2
		print(dic[not whose_turn])


from math import inf

def solve(n, arr):
	if n % 2 == 1:
		return 'Mike'
	a = inf
	b = inf
	ai = None
	bi = None
	for (i, aa) in enumerate(arr):
		if i % 2 == 0:
			if aa < a:
				a = aa
				ai = i
		elif aa < b:
			b = aa
			bi = i
	if a > b:
		return 'Mike'
	if a == b:
		if ai > bi:
			return 'Mike'
	return 'Joe'

def main():
	N = int(input())
	for _ in range(N):
		n = int(input())
		arr = list(map(int, input().split()))
		print(solve(n, arr))

def init():
	import os
	import sys
	sys.setrecursionlimit(2 * 10 ** 6)
	if 'CP_LOCAL_ENV' in os.environ:
		sys.stdin = open('cf_test_b.txt')
init()
main()


def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	if n % 2 != 0:
		print('Mike')
		return
	minn = 10000000000
	for i in range(n):
		if minn > arr[i]:
			mini = i
			minn = arr[i]
	if mini % 2 == 0:
		print('Joe')
	else:
		print('Mike')
t = int(input())
for i in range(t):
	solve()


import sys
input = sys.stdin.readline
T = int(input())
for t in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	if N % 2 == 1:
		print('Mike')
		continue
	A0 = [A[i] for i in range(0, N, 2)]
	A1 = [A[i] for i in range(1, N, 2)]
	A0min = min(A0)
	A1min = min(A1)
	if A0min > A1min:
		print('Mike')
		continue
	if A0min < A1min:
		print('Joe')
		continue
	i0 = A0.index(A0min)
	i1 = A1.index(A1min)
	print('Mike' if i0 > i1 else 'Joe')


t = int(input())
for tt in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n & 1 == 0:
		s1 = a.index(min(a))
		if s1 & 1 == 0:
			print('Joe')
		else:
			print('Mike')
	else:
		print('Mike')


def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	m = min(arr)
	k = arr.index(m)
	if n % 2 == 1:
		print('Mike')
		return
	if k % 2 == 0:
		print('Joe')
	else:
		print('Mike')
	return
for _ in range(int(input())):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	piles = list(map(int, input().split()))
	if n % 2 == 1:
		print('Mike')
	elif min(piles[::2]) < min(piles[1::2]):
		print('Joe')
	elif min(piles[::2]) > min(piles[1::2]):
		print('Mike')
	else:
		for i in range(n):
			if piles[i] == min(piles[::2]):
				break
		if i % 2 == 0:
			print('Joe')
		else:
			print('Mike')


def solve():
	n = int(input())
	l = list(map(int, input().split()))
	m = 10 ** 9 + 1
	j = 10 ** 9 + 1
	mp = -1
	jp = -1
	if n % 2 == 0:
		for i in range(n):
			if i % 2 == 0 and l[i] < m:
				m = l[i]
				mp = i
			elif l[i] < j:
				j = l[i]
				jp = i
		if j > m:
			print('Joe')
		elif j == m:
			if mp < jp:
				print('Joe')
			else:
				print('Mike')
		else:
			print('Mike')
	else:
		print('Mike')
t = int(input())
while t > 0:
	solve()
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	mi = -1
	f = False
	mmm = min(a)
	if f:
		print('Tanmay')
	for i in range(n):
		if a[i] == mmm:
			mi = i
			break
	if n % 2 == 0:
		if mi % 2 == 0:
			print('Joe')
		else:
			print('Mike')
	else:
		print('Mike')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = float('inf')
	i = 0
	if n & 1 != 0:
		print('Mike')
	else:
		for i in range(n):
			if a[i] < m:
				m = a[i]
				idx = i
		if idx & 1 == 0:
			print('Joe')
		else:
			print('Mike')


t = int(input())
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	if n % 2:
		print('Mike')
	else:
		m = lst[0]
		j = lst[1]
		pm = 0
		pj = 1
		for i in range(2, n):
			if i % 2:
				if lst[i] < j:
					j = lst[i]
					pj = i
			elif lst[i] < m:
				m = lst[i]
				pm = i
		if m > j:
			print('Mike')
		elif j > m:
			print('Joe')
		elif pm > pj:
			print('Mike')
		else:
			print('Joe')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	if n & 1:
		print('Mike')
	else:
		b = min(enumerate(a), key=lambda x: x[1])
		if b[0] & 1:
			print('Mike')
		else:
			print('Joe')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n % 2 == 1:
		print('Mike')
	else:
		k = a.index(min(a))
		if k % 2 == 1:
			print('Mike')
		else:
			print('Joe')


for k in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print('Joe' if not n % 2 and (not a.index(min(a)) % 2) else 'Mike')


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	l = [int(i) for i in input().split()]
	if n % 2 == 1:
		print('Mike')
		continue
	m = min(l)
	for i in range(0, n):
		if l[i] == m:
			if i % 2 == 1:
				print('Mike')
			else:
				print('Joe')
			break


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(i) for i in input().split(' ')]
	m = 0
	j = 0
	if n % 2 != 0:
		print('Mike')
	else:
		min_ = min(l)
		id = l.index(min_)
		if id % 2 == 0:
			if l[id] > l[id + 1]:
				print('Mike')
			else:
				print('Joe')
		elif l[id] >= l[id - 1]:
			print('Joe')
		else:
			print('Mike')


t = int(input())
while t:
	n = int(input())
	piles = list(map(int, input().split()))
	if n % 2 == 1:
		print('Mike')
	else:
		ind = piles.index(min(piles))
		if ind % 2 == 1:
			print('Mike')
		else:
			print('Joe')
	t = t - 1


t = int(input())
for k in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	lst1 = lst[0:n:2]
	lst2 = lst[1:n:2]
	if n % 2 == 0:
		a = min(lst1)
		b = min(lst2)
		if a > b:
			print('Mike')
		elif b > a:
			print('Joe')
		else:
			a1 = lst1.index(a)
			b1 = lst2.index(b)
			if a1 <= b1:
				print('Joe')
			else:
				print('Mike')
	else:
		print('Mike')


for i in range(int(input())):
	a = int(input())
	l = list(map(int, input().strip().split()))
	ans = 'Mike'
	if a % 2 == 0:
		if l.index(min(l)) % 2 == 0:
			ans = 'Joe'
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	if n % 2:
		input()
		print('Mike')
	else:
		a = [int(x) for x in input().split()]
		(i1, i2) = (0, 1)
		(m1, m2) = (a[0], a[1])
		for j in range(1, int(n / 2)):
			if a[2 * j] < m1:
				i1 = 2 * j
				m1 = a[2 * j]
			if a[2 * j + 1] < m2:
				i2 = 2 * j + 1
				m2 = a[2 * j + 1]
		if m1 < m2 or (m1 == m2 and i1 < i2):
			print('Joe')
		else:
			print('Mike')


def solve():
	n = int(input())
	lis = list(map(int, input().split()))
	if n % 2 == 0:
		Min = min(lis)
		ind = lis.index(Min)
		if ind % 2 == 1:
			print('Mike')
		else:
			print('Joe')
	else:
		print('Mike')
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	ans = -1
	if n % 2 != 0:
		ans = 0
	else:
		mi = min(lst)
		ind = lst.index(mi)
		ind = ind + 1
		if ind % 2 == 0:
			ans = 0
		else:
			ans = 1
	if ans == 1:
		print('Joe')
	else:
		print('Mike')


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = min(l)
	if n % 2 == 1:
		print('Mike')
	elif l.index(m) % 2 == 0:
		print('Joe')
	else:
		print('Mike')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if n % 2:
		print('Mike')
	else:
		m = arr.index(min(arr))
		if m % 2:
			print('Mike')
		else:
			print('Joe')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	y = arr.index(min(arr))
	if n % 2 != 0:
		print('Mike')
	elif y % 2 == 0:
		print('Joe')
	else:
		print('Mike')


n = int(input())
arr = []
for i in range(n):
	a = int(input())
	b = list(input().split(' '))
	if a % 2 != 0:
		arr.append('Mike')
	else:
		min1 = 10000000000
		index = -1
		for i in range(a):
			if min1 > int(b[i]):
				index = i
				min1 = int(b[i])
		if index % 2 == 0:
			arr.append('Joe')
		else:
			arr.append('Mike')
for i in arr:
	print(i)


for i in range(int(input())):
	num = int(input())
	lis = list(map(int, input().split(' ')))
	if num % 2 == 0:
		mi = min(lis)
		idx = lis.index(mi)
		if idx % 2 == 0:
			print('Joe')
		else:
			print('Mike')
	else:
		print('Mike')


for t in range(int(input())):
	if int(input()) % 2 == 1:
		print('Mike')
		no_use = input()
		continue
	else:
		piles = [int(ai) for ai in input().split()]
		ind = piles.index(min(piles)) + 1
		if ind % 2 == 1:
			print('Joe')
		else:
			print('Mike')
		continue


strng = lambda : input()
inp = lambda : int(input())
mul = lambda : map(int, input().split())
jn = lambda x, l: x.join(map(str, l))
strlst = lambda : list(input())
lst = lambda : list(map(int, input().split()))
dd = lambda : defaultdict(lambda : 0)
import sys
input = sys.stdin.readline
from collections import defaultdict
from math import ceil, log, floor, sqrt, gcd, log10
for _ in range(inp()):
	n = inp()
	a = lst()
	if n & 1:
		print('Mike')
		continue
	mini = sys.maxsize
	pos = 0
	for i in range(n):
		if a[i] < mini:
			mini = a[i]
			pos = i
	if pos + 1 & 1:
		print('Joe')
		continue
	print('Mike')


t = int(input())
for i in range(t):
	n = int(input())
	my_list = list(map(int, input().split()))
	if n % 2 != 0:
		print('Mike')
		continue
	x = min(my_list)
	index = my_list.index(x)
	if (index + 1) % 2 != 0:
		print('Joe')
	else:
		print('Mike')


for _ in range(int(input())):
	N = int(input())
	list1 = list(map(int, input().split()))
	Min = min(list1)
	index = list1.index(Min)
	if N % 2 == 0:
		if index % 2 != 0:
			print('Mike')
		else:
			print('Joe')
	else:
		print('Mike')


t = int(input())
for i in range(t):
	n = int(input())
	z = list(map(int, input().split()))
	if n % 2 == 1:
		print('Mike')
	elif z.index(min(z)) % 2 == 0:
		print('Joe')
	else:
		print('Mike')


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip().split()))[:n]
	mn = min(a)
	b = a.index(mn)
	if n % 2 != 0:
		print('Mike')
	if n % 2 == 0:
		if b % 2 == 0:
			print('Joe')
		else:
			print('Mike')


c = int(input())
for i in range(c):
	k = int(input())
	x = list(map(int, input().split()))
	minarg = x.index(min(x))
	if k % 2 == 1:
		print('Mike')
	elif k % 2 == 0 and minarg % 2 == 0:
		print('Joe')
	else:
		print('Mike ')


for i in range(int(input())):
	a = int(input())
	n = list(map(int, input().split()))
	if a % 2 == 1:
		x = 'Mike'
	elif n.index(min(n)) % 2 == 1:
		x = 'Mike'
	else:
		x = 'Joe'
	print(x)


_ = int(input())
for __ in range(_):
	n = int(input())
	arr = list(map(int, input().split()))
	if len(arr) % 2 == 1:
		print('Mike')
	else:
		p = min(arr)
		ppos = arr.index(p)
		if ppos % 2 == 1:
			print('Mike')
		else:
			print('Joe')


T = int(input())
q = []
for i in range(T):
	n = int(input())
	data = [int(i) for i in input().split()]
	q.append((n, data))

def solve(n, data):
	if n % 2:
		print('Mike')
		return
	sum_m = 10000000000.0
	pos_m = 0
	sum_j = 10000000000.0
	pos_j = 0
	for i in range(n):
		if i % 2:
			if data[i] < sum_j:
				sum_j = data[i]
				pos_j = i
		elif data[i] < sum_m:
			sum_m = data[i]
			pos_m = i
	if sum_m > sum_j:
		print('Mike')
	elif sum_m == sum_j:
		if pos_m < pos_j:
			print('Joe')
		else:
			print('Mike')
	else:
		print('Joe')
for (n, data) in q:
	solve(n, data)


x = int(input())
for i in range(x):
	y = int(input())
	A = input().split()
	if y % 2 == 1:
		print('Mike')
	else:
		mini = int(A[0])
		minj = 0
		for j in range(y):
			if int(A[j]) < mini:
				mini = int(A[j])
				minj = j
		if minj % 2 == 0:
			print('Joe')
		else:
			print('Mike')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if n % 2 != 0:
		print('Mike')
	else:
		x = min(arr)
		ind = arr.index(x)
		if ind % 2 == 0:
			print('Joe')
		else:
			print('Mike')


import math
from collections import Counter

def fun(a):
	if len(a) % 2:
		return 'Mike'
	else:
		if a.index(min(a)) % 2:
			return 'Mike'
		return 'Joe'
n = int(input())
for _ in range(n):
	l = input()
	a = input().split()
	a = list(map(int, a))
	print(fun(a))


num_of_case = int(input())
for _ in range(num_of_case):
	N = int(input())
	arr = [int(x) for x in input().split(' ')]
	if N % 2 == 1:
		print('Mike')
	else:
		m = min(arr)
		idx = arr.index(m)
		print('Mike') if idx % 2 == 1 else print('Joe')


for _ in range(int(input())):
	n = int(input())
	g = list((int(i) for i in input().split()))
	if n % 2 != 0:
		print('Mike')
	else:
		x = g.index(min(g))
		if x % 2 == 0:
			print('Joe')
		else:
			print('Mike')


t = int(input())
ar = [[] for i in range(t)]
(p1, p2) = ('Mike', 'Joe')
for i in range(t):
	n = int(input())
	ar[i] += [int(o) for o in input().split()]
for i in range(t):
	if len(ar[i]) % 2 == 1:
		print('Mike')
	else:
		smallest = 0
		for j in range(len(ar[i])):
			if ar[i][j] < ar[i][smallest]:
				smallest = j
		if smallest % 2 == 0:
			print('Joe')
		else:
			print('Mike')


a = int(input())
for w in range(a):
	l = int(input())
	L = [int(s) for s in input().split()]
	if l % 2 != 0:
		print('Mike')
	elif L.index(min(L)) % 2 == 0:
		print('Joe')
	else:
		print('Mike')


t = int(input())
for i in range(t):
	n = int(input())
	a = input().split()
	for i in range(n):
		a[i] = int(a[i])
	if n % 2 == 1:
		print('Mike')
		continue
	minindex = a.index(min(a))
	if minindex % 2 == 0:
		print('Joe')
	else:
		print('Mike')


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	res = l.index(min(l))
	if n == 1:
		print('Mike')
		continue
	if res % 2 == 0 and n % 2 == 0:
		print('Joe')
	else:
		print('Mike')


for _ in range(int(input())):
	n = int(input())
	piles = list(map(int, input().split()))
	if n % 2:
		print('Mike')
	elif piles.index(min(piles)) % 2:
		print('Mike')
	else:
		print('Joe')


t = int(input())
for _ in range(t):
	n = input()
	arr = list(map(int, input().split()))
	if len(arr) % 2 == 1:
		print('Mike')
		continue
	j = arr.index(min(arr))
	if j % 2:
		print('Mike')
	else:
		print('Joe')