from itertools import combinations
from functools import lru_cache

class Solver():
    def __init__(self, N, numbers):
        self.N = N
        self.numbers = numbers

    @lru_cache(maxsize=40000)
    def dfs(self, numbers):

        score = sum(numbers)
        if len(numbers) == 1:
            return score

        if len(numbers) == 2:
            return score * 2

        results = []
        index = list(range(len(numbers)))
        # for each split pattern
        for k in range(len(numbers) // 2):
            for c in combinations(index, k + 1):
                g1 = [numbers[i] for i in index if i in c]
                g2 = [numbers[i] for i in index if i not in c]

                if len(g1) == 1:
                    score1 = g1[0]
                elif len(g1) == 2:
                    score1 = sum(g1)*2
                else:
                    score1 = dfs(tuple(g1))

                if len(g2) == 1:
                    score2 = g2[0]
                elif len(g2) == 2:
                    score2 = sum(g2)*2
                else:
                    score2 = dfs(tuple(g2))

                #print('g1 ->', g1)
                #print('g2 ->', g2)
                results.append(score1 + score2)

        #print(numbers, results)
        #print(numbers, '->' ,results, max(results) + score)

        return max(results) + score

    def solve(self):
        return self.dfs(tuple(self.numbers))

if __name__ == "__main__":
    N = int(input())
    numbers = list(map(int, input().split()))
    s = Solver(N, numbers)
    print(s.solve())


from itertools import combinations
from functools import lru_cache

class Solver():
    def __init__(self, N, numbers):
        self.N = N
        self.numbers = numbers

    @lru_cache(maxsize=10000)
    def dfs(self, numbers):

        score = sum(numbers)
        if len(numbers) == 1:
            return score

        if len(numbers) == 2:
            return score * 2

        results = []
        index = list(range(len(numbers)))
        # for each split pattern
        for k in range(len(numbers) // 2):
            for c in combinations(index, k + 1):
                g1 = [numbers[i] for i in index if i in c]
                g2 = [numbers[i] for i in index if i not in c]

                if len(g1) == 1:
                    score1 = g1[0]
                elif len(g1) == 2:
                    score1 = sum(g1)*2
                else:
                    score1 = self.dfs(tuple(sorted(g1)))

                if len(g2) == 1:
                    score2 = g2[0]
                elif len(g2) == 2:
                    score2 = sum(g2)*2
                else:
                    score2 = self.dfs(tuple(sorted(g2)))

                #print('g1 ->', g1)
                #print('g2 ->', g2)
                results.append(score1 + score2)

        #print(numbers, results)
        #print(numbers, '->' ,results, max(results) + score)

        return max(results) + score

    def solve(self):
        return self.dfs(tuple(self.numbers))

if __name__ == "__main__":
    N = int(input())
    numbers = list(map(int, input().split()))
    s = Solver(N, numbers)
    print(s.solve())


from itertools import combinations
from functools import lru_cache

class Solver():
    def __init__(self, N, numbers):
        self.N = N
        self.numbers = numbers

    @lru_cache(maxsize=None)
    def dfs(self, numbers):
        # Appleman
        score = sum(numbers)
        if len(numbers) == 1:
            return score

        results = []

        # for each split pattern
        for k in range(len(numbers) // 2):
            for c in combinations(numbers, k + 1):
                g1 = c
                #print('g1 ->', g1)
                g2 = [x for x in numbers if x not in c]
                #print('g2 ->', g2)
                results.append(self.dfs(tuple(g1)) + self.dfs(tuple(g2)))

        #print(numbers, '->' ,results, max(results) + score)

        return max(results) + score

    def solve(self):
        return self.dfs(tuple(self.numbers))

if __name__ == "__main__":
    N = int(input())
    numbers = list(map(int, input().split()))
    s = Solver(N, numbers)
    print(s.solve())


from itertools import combinations
from functools import lru_cache

class Solver():
    def __init__(self, N, numbers):
        self.N = N
        self.numbers = numbers

    @lru_cache(maxsize=40000)
    def dfs(self, numbers):

        score = sum(numbers)
        if len(numbers) == 1:
            return score

        if len(numbers) == 2:
            return score * 2

        results = []
        index = list(range(len(numbers)))
        # for each split pattern
        for k in range(len(numbers) // 2):
            for c in combinations(index, k + 1):
                g1 = [numbers[i] for i in index if i in c]
                g2 = [numbers[i] for i in index if i not in c]

                if len(g1) == 1:
                    score1 = g1[0]
                elif len(g1) == 2:
                    score1 = sum(g1)*2
                else:
                    score1 = self.dfs(tuple(g1))

                if len(g2) == 1:
                    score2 = g2[0]
                elif len(g2) == 2:
                    score2 = sum(g2)*2
                else:
                    score2 = self.dfs(tuple(g2))

                #print('g1 ->', g1)
                #print('g2 ->', g2)
                results.append(score1 + score2)

        #print(numbers, results)
        #print(numbers, '->' ,results, max(results) + score)

        return max(results) + score

    def solve(self):
        return self.dfs(tuple(self.numbers))

if __name__ == "__main__":
    N = int(input())
    numbers = list(map(int, input().split()))
    s = Solver(N, numbers)
    print(s.solve())


from itertools import combinations
from functools import lru_cache

class Solver():
    def __init__(self, N, numbers):
        self.N = N
        self.numbers = numbers

    @lru_cache(maxsize=None)
    def dfs(self, numbers):

        score = sum(numbers)
        if len(numbers) == 1:
            return score

        if len(numbers) == 2:
            return score * 2

        results = []
        index = list(range(len(numbers)))
        # for each split pattern
        for k in range(len(numbers) // 2):
            for c in combinations(index, k + 1):
                g1 = [numbers[i] for i in index if i in c]
                g2 = [numbers[i] for i in index if i not in c]
                #print('g1 ->', g1)
                #print('g2 ->', g2)
                results.append(self.dfs(tuple(g1)) + self.dfs(tuple(g2)))

        #print(numbers, results)
        #print(numbers, '->' ,results, max(results) + score)

        return max(results) + score

    def solve(self):
        return self.dfs(tuple(self.numbers))

if __name__ == "__main__":
    N = int(input())
    numbers = list(map(int, input().split()))
    s = Solver(N, numbers)
    print(s.solve())


from itertools import combinations
from functools import lru_cache

class Solver():
    def __init__(self, N, numbers):
        self.N = N
        self.numbers = numbers

    @lru_cache(maxsize=10000)
    def dfs(self, numbers):

        score = sum(numbers)
        if len(numbers) == 1:
            return score

        if len(numbers) == 2:
            return score * 2

        results = []
        index = list(range(len(numbers)))
        # for each split pattern
        for k in range(len(numbers) // 2):
            for c in combinations(index, k + 1):
                g1 = [numbers[i] for i in index if i in c]
                g2 = [numbers[i] for i in index if i not in c]

                if len(g1) == 1:
                    score1 = g1[0]
                elif len(g1) == 2:
                    score1 = sum(g1)*2
                else:
                    score1 = self.dfs(tuple(g1))

                if len(g2) == 1:
                    score2 = g2[0]
                elif len(g2) == 2:
                    score2 = sum(g2)*2
                else:
                    score2 = self.dfs(tuple(g2))

                #print('g1 ->', g1)
                #print('g2 ->', g2)
                results.append(score1 + score2)

        #print(numbers, results)
        #print(numbers, '->' ,results, max(results) + score)

        return max(results) + score

    def solve(self):
        return self.dfs(tuple(self.numbers))

if __name__ == "__main__":
    N = int(input())
    numbers = list(map(int, input().split()))
    s = Solver(N, numbers)
    print(s.solve())


from itertools import combinations
from functools import lru_cache

class Solver():
    def __init__(self, N, numbers):
        self.N = N
        self.numbers = numbers

    @lru_cache(maxsize=20000)
    def dfs(self, numbers):
        score = sum(numbers)

        results = []
        index = list(range(len(numbers)))
        # for each split pattern
        for k in range(len(numbers) // 2):
            for c in combinations(index, k + 1):
                g1 = [numbers[i] for i in index if i in c]
                g2 = [numbers[i] for i in index if i not in c]

                if len(g1) == 1:
                    score1 = g1[0]
                elif len(g1) == 2:
                    score1 = sum(g1)*2
                else:
                    score1 = dfs(tuple(g1))

                if len(g2) == 1:
                    score2 = g2[0]
                elif len(g2) == 2:
                    score2 = sum(g2)*2
                else:
                    score2 = dfs(tuple(g2))

                #print('g1 ->', g1)
                #print('g2 ->', g2)
                results.append(score1 + score2)

        #print(numbers, results)
        #print(numbers, '->' ,results, max(results) + score)

        return max(results) + score

    def solve(self):
        return self.dfs(tuple(self.numbers))

if __name__ == "__main__":
    N = int(input())
    numbers = list(map(int, input().split()))
    s = Solver(N, numbers)
    print(s.solve())


from itertools import combinations
from functools import lru_cache

class Solver():
    def __init__(self, N, numbers):
        self.N = N
        self.numbers = numbers

    @lru_cache(maxsize=1000)
    def dfs(self, numbers):

        score = sum(numbers)
        if len(numbers) == 1:
            return score

        if len(numbers) == 2:
            return score * 2

        results = []
        index = list(range(len(numbers)))
        # for each split pattern
        for k in range(len(numbers) // 2):
            for c in combinations(index, k + 1):
                g1 = [numbers[i] for i in index if i in c]
                g2 = [numbers[i] for i in index if i not in c]

                if len(g1) == 1:
                    score1 = g1[0]
                elif len(g1) == 2:
                    score1 = sum(g1)*2
                else:
                    score1 = self.dfs(tuple(g1))

                if len(g2) == 1:
                    score2 = g2[0]
                elif len(g2) == 2:
                    score2 = sum(g2)*2
                else:
                    score2 = self.dfs(tuple(g2))

                #print('g1 ->', g1)
                #print('g2 ->', g2)
                results.append(score1 + score2)

        #print(numbers, results)
        #print(numbers, '->' ,results, max(results) + score)

        return max(results) + score

    def solve(self):
        return self.dfs(tuple(self.numbers))

if __name__ == "__main__":
    N = int(input())
    numbers = list(map(int, input().split()))
    s = Solver(N, numbers)
    print(s.solve())


from itertools import combinations
from functools import lru_cache

class Solver():
    def __init__(self, N, numbers):
        self.N = N
        self.numbers = numbers
        self.index = list(range(len(numbers)))

    @lru_cache(maxsize=None)
    def dfs(self, numbers):

        score = sum(numbers)
        if len(numbers) == 1:
            return score

        if len(numbers) == 2:
            return score * 2

        results = []
        # for each split pattern
        for k in range(len(numbers) // 2):
            for c in combinations(self.index, k + 1):
                g1 = [numbers[i] for i in self.index if i in c]
                g2 = [numbers[i] for i in self.index if i not in c]
                #print('g1 ->', g1)
                #print('g2 ->', g2)
                results.append(self.dfs(tuple(g1)) + self.dfs(tuple(g2)))

        #print(numbers, results)
        #print(numbers, '->' ,results, max(results) + score)

        return max(results) + score

    def solve(self):
        return self.dfs(tuple(self.numbers))

if __name__ == "__main__":
    N = int(input())
    numbers = list(map(int, input().split()))
    s = Solver(N, numbers)
    print(s.solve())


from collections import deque

class Solver():
    def __init__(self, N, numbers):
        self.N = N
        self.numbers = deque(sorted(numbers))
        self.total = sum(numbers)

    def solve(self):
        numbers = self.numbers
        score = self.total

        if len(numbers) == 1:
            return score

        n1 = numbers.pop()
        n2 = numbers.pop()

        score += n1
        score += n2

        tmp = n1 + n2
        while len(numbers) > 0:
            x = numbers.pop()
            #print(score+x+tmp, '<-', score, '+', tmp, '+', x)
            score += x
            score += tmp
            tmp += x

        return score

if __name__ == "__main__":
    N = int(input())
    numbers = list(map(int, input().split()))
    s = Solver(N, numbers)
    print(s.solve())


from itertools import combinations
from functools import lru_cache

@lru_cache(maxsize=10000)
def dfs(numbers):

    score = sum(numbers)
    if len(numbers) == 1:
        return score

    if len(numbers) == 2:
        return score * 2

    results = []
    index = list(range(len(numbers)))
    # for each split pattern
    for k in range(len(numbers) // 2):
        for c in combinations(index, k + 1):
            g1 = [numbers[i] for i in index if i in c]
            g2 = [numbers[i] for i in index if i not in c]

            if len(g1) == 1:
                score1 = g1[0]
            elif len(g1) == 2:
                score1 = sum(g1)*2
            else:
                score1 = dfs(tuple(sorted(g1)))

            if len(g2) == 1:
                score2 = g2[0]
            elif len(g2) == 2:
                score2 = sum(g2)*2
            else:
                score2 = dfs(tuple(sorted(g2)))

            #print('g1 ->', g1)
            #print('g2 ->', g2)
            results.append(score1 + score2)

    #print(numbers, results)
    #print(numbers, '->' ,results, max(results) + score)

    return max(results) + score

N = int(input())
numbers = list(map(int, input().split()))
print(dfs(numbers))


n = int(input())
A = sorted(list(map(int,input().split())))

ans = sum(A)
cnt = 1
for i,a in enumerate(A):
    ans += a*cnt if i != n-1 else a*(cnt-1)
    cnt += 1
    # print(ans,a,i)
print(ans)


n = int(input())
numbers =  map(int,input().split(' '))
numbers = sorted(numbers, key=None, reverse=True)
sums = []
ant = 0
for x in numbers:
        ant+=x
        sums.append(ant)

res = 0
tam = 0
#print(numbers)
#print(sums)
for x1,x2 in zip(numbers,sums):
    if tam >= 2:
        res+=x1+x2
        #print(res)
    elif tam == 1:
        res+= sums[1]*2
    tam+=1
if n == 1: res+=sums[0]

    #print(res)
print(res)


n=int(input());a=[];z=0
for i in range(n) :
    b=list(input())
    a.append(b)
c=a[0][0];d=a[0][1]
for i in a :
    for j in i :
        if j==c or j==d :
            z+=1
if z==pow(n,2) :
    print("YES")
else :
    print("NO")


n=int(input());a=[];z=0
for i in range(n) :
    b=list(input())
    a.append(b)
c=a[0][0];d=a[0][1];e=a[0][len(a)-1]
if c==d :
    print("NO")
elif c!=e :
    print("NO")
else :
    for i in range(len(a)) :
        for j in range(len(a)) :
            if i==j or i+j==n-1 :
                if a[i][j]==c :
                    z+=1
            else :
                if a[i][j]==d :
                    z+=1
    if z==(n*n) :
        print("YES")
    else :
        print("NO")


n=int(input())
a=[];c=0
for i in range(n) :
    b=list(set(input()))
    a.append(b)
for i in a :
    if len(i)==2 :
        c+=1
if c==n :
    print("YES")
else :
    print("NO")


n=int(input())
a=[]
for i in range(n) :
    b=list(map(int,input()))
    a.append(b)
x=a[0][0];y=a[0][1];z=a[0][n-1]
p=q=r=0
for i in range(n) :
    for j in range(n) :
        if i==j :
            if a[i][j]==x :
                p+=1
        elif i+j==n-1 :
            if a[i][j]==y :
                q+=1
        elif i!=j :
            if a[i][j]==z :
                r+=1
if p+q+r==(n*n) :
    print("YES")
else :
    print("NO")


n=int(input())
a=[]
for i in range(n) :
    b=list(input())
    a.append(b)
x=a[0][0];y=a[0][1];z=a[0][n-1]
p=q=r=0
for i in range(n) :
    for j in range(n) :
        if i==j :
            if a[i][j]==x :
                p+=1
        elif i+j==n-1 :
            if a[i][j]==y :
                q+=1
        elif i!=j :
            if a[i][j]==z :
                r+=1
if p+q+r==(n*n) :
    print("YES")
else :
    print("NO")


n,r=int(input()),""
for i in range(n):r+=input()
if len(set(r))!=2:print("NO")
else:
    for i in range(0,n*n,n):
        s=r[i:i+n]
        o=i//n
        if s[o]!=r[0]or s[n-1-o]!=r[0]or s.count(r[0])>1+int(o!=n-o-1):exit(print("NO"))
    print("YES")


n,r=int(input()),""
for i in range(n):r+=input()
if len(set(r))!=2:print("NO","JKLL")
else:
    for i in range(0,n*n,n):
        s=r[i:i+n]
        o=i//n
        if s[o]!=r[0]or s[n-1-o]!=r[0]or s.count(r[0])>2:exit(print("NO"))
    print("YES")


n,r=int(input()),""
for i in range(n):r+=input()
if len(set(r))!=2:print("NO","JKLL")
else:
    for i in range(0,n*n,n):
        s=r[i:i+n]
        o=i//n
        if s[o]!=r[0]or s[n-1-o]!=r[0]or s.count(r[0])>1+int(o!=n-o-1):exit(print("NO"))
    print("YES")


n,r=int(input()),""
for i in range(n):r+=input()
if len(set(r))!=2:print("NO")
else:
    for i in range(0,n*n,n):
        s=r[i:i+n]
        o=i//n
        if s[o]!=r[0]or s[n-1-o]!=r[0]or s.count(r[0])>2:exit(print("NO"))
    print("YES")


a = int(input())
b=[]
c=[]
for i in range(a):
    t = list(input())
    b.append(t)
    for j in t:
        c.append(j)
if len(set(c))!=2:
    print('NO')
elif c.count(c[0])!=2*a-1:
    print('NO')
elif c.count(c[1])!=a**2-(2*a-1):
    print('NO')
else:
    print('YES')


a = int(input())
mid = a//2
b=[]
c=[]
for i in range(a):
    t = list(input())
    b.append(t)
    for j in t:
        c.append(j)
if len(set(c))!=2:
    print('NO')
elif c.count(c[0])!=2*a-1:
    print('NO')
elif c.count(c[1])!=a**2-(2*a-1):
    print('NO')
elif b[mid][mid]!=b[0][0] or b[a-1][a-1]!=b[0][0]:
    print('NO')
elif b[a-1][0]!=b[mid][mid] or b[a-1][0]!=b[0][a-1]:
    print('NO')
else:
    print('YES')


a = int(input())
mid = a//2
b=[]
c=[]
for i in range(a):
    t = list(input())
    b.append(t)
    for j in t:
        c.append(j)
if len(set(c))!=2:
    print('NO')
elif c.count(c[0])!=2*a-1:
    print('NO')
elif c.count(c[1])!=a**2-(2*a-1):
    print('NO')
elif b[mid][mid]!=b[0][0] or b[a-1][a-1]!=b[0][0]:
    print('NO')
elif b[a-1][0]!=b[mid][mid] or b[a-1][0]!=b[0][a-1]:
    print('NO')
elif b[0][0]!=b[1][1]:
    print('NO')
else:
    print('YES')


x = int(input())
l=list()
for i in range(x):
	l.append(list(input()))
flag='YES'
for i in range(x):
	for j in range(x):
		if i==j:
			if l[i][i]!=l[0][0] or l[i][x-i-1]!=l[0][0]:
				flag='NO'
#####			print(i,j,0)
		elif i!=j and j!=x-i-1:
			if l[i][j]!=l[0][1]:
				flag='NO'
#####				print(i,j,2)
print(flag)


x = int(input())
l=list()
for i in range(x):
	l.append(list(input()))
flag='YES'
for i in range(x):
	for j in range(x):
		if i==j:
			if l[i][i]!=l[0][0] or l[i][x-i-1]!=l[0][0]:
				flag='NO'
				print(i,j,0)
		elif i!=j and j!=x-i-1:
			if l[i][j]!=l[0][1]:
				flag='NO'
				print(i,j,2)
print(flag)


x = int(input())
l=list()
for i in range(x):
	l.append(list(input()))
flag='YES'
for i in range(x):
	for j in range(x):
		if i==j:
			if l[i][i]!=l[0][0] or l[i][x-i-1]!=l[0][0]:
				flag='NO'
#				print(i,j,0)
		elif i!=j and j!=x-i-1:
			if l[i][j]!=l[0][1]:
				flag='NO'
#				print(i,j,2)
print(flag)


x = int(input())
l=list()
for i in range(x):
	l.append(list(input()))
flag='YES'
for i in range(x):
	for j in range(x):
		if i==j:
			if l[i][i]!=l[0][0] or l[i][x-i-1]!=l[0][0]:
				flag='NO'
#####			print(i,j,0)
		elif i!=j and j!=x-i-1:
			if l[i][j]!=l[0][1] or l[i][j]==l[0][0]:
				flag='NO'
#####				print(i,j,2)
print(flag)


from collections import Counter
N = int(input())
matrix = []
for i in range(N):
    matrix.append([x for x in input()])
for i in matrix:
    if len(Counter(i).keys()) != 2:
        print("NO")
        exit()
for i in range((N//2)+1):
    if i == (N//2):
        if matrix[i].count(matrix[i][i]) != 1:
            print("NO")
            exit()
    else:
        if matrix[i].count(matrix[i][i]) != 2:
            print("NO")
            exit()
    if matrix[i][i] != matrix[-(i+1)][-(i+1)]:
        print("NO")
        exit()
print("YES")


N = int(input())
matrix = []
for i in range(N):
    matrix.append([x for x in input()])
A = matrix[0][0]
B = matrix[0][1]
for i in range(N):
    for j in range(N):
        if i == j:
            if A != matrix[i][j]:
                print("NO")
                exit()
        elif i == N-1-j:
            if A != matrix[i][j]:
                print("NO")
                exit()
        else:
            if B != matrix[i][j] or A == matrix[i][j]:
                print("NO")
                exit()
print("YES")


from collections import Counter
N = int(input())
matrix = []
for i in range(N):
    matrix.append([x for x in input()])
for i in matrix:
    if len(Counter(i).keys()) != 2:
        print("NO")
        exit()
for i in range((N//2)+1):
    if matrix[i][i] != matrix[-(i+1)][-(i+1)]:
        print("NO")
        exit()
print("YES")


from collections import Counter
N = int(input())
matrix = []
for i in range(N):
    matrix.append([x for x in input()])
for i in range(1,N):
    if Counter(matrix[i]).keys() != Counter(matrix[i-1]).keys():
        print("NO")
        exit()
for i in matrix:
    if len(Counter(i).keys()) != 2:
        print("NO")
        exit()
for i in range((N//2)+1):
    if i == (N//2):
        if matrix[i].count(matrix[i][i]) != 1:
            print("NO")
            exit()
    else:
        if matrix[i].count(matrix[i][i]) != 2:
            print("NO")
            exit()
    if matrix[i][i] != matrix[-(i+1)][-(i+1)]:
        print("NO")
        exit()
print("YES")


n=int(input())
a=[]
for i in range(n):
    a.append(input())
a=' '.join(a)
if a.count(a[1])==n**2-(n+n-1) and a.count(a[0])==n+n-1:

  if  a[::]==a[::-1]:
   print('YES')
  else:
   print('NO')

else:
  print('NO')


n=int(input())
a=[]
for i in range(n):
  a.append(input())
if a[::]==a[::-1]:
  print('YES')
else:
  print('NO')


n=int(input())
A=[]
B=[]
c='YES'
s=''
for i in range(n):
    A.append(input())
if A[0]!=A[-1]:
    print('NO')
else:

    a=A[1][-1]

    for i in range(-1,-1*n,-1):
        if A[-i][i]!=a:
            c='NO'
            break
    a=A[0][0]
    for i in range(0,n):
        if A[i][i]!=a:
            c='NO'

    if c=='YES':
        for i in range(n):
            for j in A:
                s+=j[i]
            B.append(s)
            s=''
    for i in B:
        if B[0]!=B[-1]:
            c='NO'
    print(c)


n=int(input())
A=[]
B=[]
c='YES'
s=''
for i in range(n):
    A.append(input())
if A[0]!=A[-1]:
    print('NO')
else:

    a=A[1][-1]

    for i in range(-1,-1*n,-1):
        if A[-i][i]!=a:
            c='NO'
            break
    a=A[0][0]
    for i in range(0,n):
        if A[i][i]!=a:
            c='NO'

    if c=='YES':
        for i in range(n):
            for j in A:
                s+=j[i]
            B.append(s)
            s=''
    for i in B:
        if B[0]!=B[-1]:
            c='NO'
    if c=='YES':
        if n*2-1!=A.count(A[-1][-1]):

            c='NO'
    print(c)


n=int(input())
a=[]
for i in range(n):
  a.append(input())
a=' '.join(a)
if a[::]==a[::-1]:
  print('YES')
else:
  print('NO')


n = int(input())
x = []
c = -1
d1 = ""
d2 = ""
others=""
for i in range(n):
    x.append(list(map(str, input().split())))
    d1+=x[i][0][i]
    d2+=x[i][0][c]
    current=x[i][0]
    if i==((n+1)//2)-1:
        current=current.replace(d1[-1],"",1)
    else:
        current = current.replace(d1[-1], "", 1)
        current = current.replace(d2[-1], "", 1)
    others+=current
    c-=1
if d1==d2 and len(set(others))==1 and others[0]!=d1[0] and len(set(d1))==1:
    print('YES')
else:
    print('NO')


n = int(input())
x = []
c = -1
d1 = ""
d2 = ""
others=""
for i in range(n):
    x.append(list(map(str, input().split())))
    d1+=x[i][0][i]
    d2+=x[i][0][c]
    current=x[i][0]
    current=current.replace(d1[-1],"",1)
    current = current.replace(d2[-1], "", 1)
    others+=current
    c-=1
if d1==d2 and len(set(others))==1 and others[0]!=d1[0] and len(set(d1))==1:
    print('YES')
else:
    print('NO')


n = int(input())
x = []
c = -1-1+1
d1 = ""
d2 = ""
others=""
for i in range(n):
    x.append(list(map(str, input().split())))
    d1+=x[i][0][i]
    d2+=x[i][0][c]
    current=x[i][0]
    if i==((n+1)//2)-1:
        current=current.replace(d1[-1],"",1)
    else:
        current = current.replace(d1[-1], "", 1)
        current = current.replace(d2[-1], "", 1)
    others+=current
    c-=1
if d1==d2 and len(set(others))==1 and others[0]!=d1[0] and len(set(d1))==1:
    print('YES')
else:
    print('NO')


n = int(input())
x = []
c = -1
d1 = ""
d2 = ""
others=""
for i in range(n):
    x.append(list(map(str, input().split())))
    d1+=x[i][0][i]
    d2+=x[i][0][c]
    current=x[i][0]
    current=current.replace(d1[-1],"",1)
    current = current.replace(d2[-1], "", 1)
    others+=current
    c-=1
if d1==d2 and len(set(others))==1 and others[0]!=d1[0]:
    print('YES')
else:
    print('NO')


n =int(input())
arr=[]
for _ in range(n):
    arr.append(input())
j = 0 ; x = (n-1)
d2 = arr[0][1]
d1 = arr[0][0]
for i in range(0,n):
    for ll in range(0,n):
        if (i==j or i==x):continue
        elif (arr[i][ll]==d2) :continue
        else : print('NO') ; quit()
    if (arr[i][j]==arr[i][x]):
        if (i > (n // 2)):
            j-=1 ; x+=1
        else : j+=1 ; x-=1
    else : print('NO');quit()

print('YES')


n =int(input())
arr=[]
for _ in range(n):
    arr.append(input())
j = 0 ; x = (n-1)
d2 = arr[0][1]
d1 = arr[0][0]
for i in range(0,n):
    for ll in range(0,n):
        if (i==j or i==x):continue
        elif (arr[i][ll]==d2) :continue
        else : print('NO') ; quit()
    if (arr[i][j]==arr[i][x]==d1):
        if (i >=(n // 2)):
            j-=1 ; x+=1
        else : j+=1 ; x-=1
    else : print('NO');quit()

print('YES')


n =int(input())
arr=[]
for _ in range(n):
    arr.append(input())
j = 0 ; x = (n-1)
d2 = arr[0][1]
d1 = arr[0][0]
for i in range(0,n):
    for ll in range(0,n):
        if (i==j or i==x):continue
        elif (arr[i][ll]==d2) :continue
        else : print('NoO') ; quit()
    if (arr[i][j]==arr[i][x]==d1):
        if (i >=(n // 2)):
            j-=1 ; x+=1
        else : j+=1 ; x-=1
    else : print('NO');quit()

print('YES')


#Valera and X
n = int(input())
arr = [input() for _ in range(n)]
a=arr[0][0]; b=arr[0][1]
j=0;nn=n-1;arr2=[]
for i in range(0,n):
    c=''
    for xx in range(0,n):
        if(xx==j or xx==nn):c+=a
        else : c+=b
    if (i >= n//2):j-=1;nn+=1
    else :j+=1;nn-=1
    arr2.append(c)
if arr2==arr :
    print('YES')
else : print('NO')


n =int(input())
arr=[]
for _ in range(n):
    arr.append(input())
j = 0 ; x = (n-1)
d2 = arr[0][1]
d1 = arr[0][0]
for i in range(0,n):
    for ll in range(0,n):
        if (i==j or i==x):continue
        elif (arr[i][ll]==d2) :continue
        else : print('NO') ; quit()
    if (arr[i][j]==arr[i][x]==d1):
        if (i >(n // 2)):
            j-=1 ; x+=1
        else : j+=1 ; x-=1
    else : print('NO');quit()

print('YES')


#Valera and X
n = int(input())
arr = [input() for _ in range(n)]
a=arr[0][0]; b=arr[0][1]
if a == b : print('NO');quit()
j=0;nn=n-1;arr2=[]
for i in range(0,n):
    c=''
    for xx in range(0,n):
        if(xx==j or xx==nn):c+=a
        else : c+=b
    if (i >= n//2):j-=1;nn+=1
    else :j+=1;nn-=1
    arr2.append(c)
if arr2==arr :
    print('YES')
else : print('NO')


n= int(input())
mat=[]
s=''
count1=0
count2=0

for i in range(n):
    temp= input()
    s+=temp
    temp= list(temp)
    mat.append(temp)

t=mat[0][0]
if len(set(s))>2:
    print('NO')
else:
    for i in range(n):
        for j in range(n):
            if i==j:
                if mat[i][j]==t:
                    count1+=1
            elif i+j==n-1:
                if mat[i][j]==t:
                    count2+=1
    if count1==n and count2==n-1:
        print('YES')
    else:
        print('NO')


n= int(input())
mat=[]
s=''
count1=0
count2=0

for i in range(n):
    temp= input()
    s+=temp
    temp= list(temp)
    mat.append(temp)

t=mat[0][0]
if len(set(s))!=2:
    print('NO')
else:
    for i in range(n):
        for j in range(n):
            if i==j:
                if mat[i][j]==t:
                    count1+=1
            elif i+j==n-1:
                if mat[i][j]==t:
                    count2+=1
    if count1==n and count2==n-1:
        print('YES')
    else:
        print('NO')


n = int(input())
s = ''
for i in range(n):
	s += input()
if s == ''.join(list(reversed(s))) and s.count(s[0]) == (n*2) - 1:
	print("YES")
else:
	print("NO")


n = int(input())
l = []
for _ in range(n):
    l.append(list(input()))

s = set()
i, j = 0, n-1
dig = True
p = l[0][0]
for x in l:
    if x[i] != x[j] or x[i] != p:
        dig = False
        break
    if l.count(p) > 2 and i != j:
        dig = False
        break
    elif l.count(p) > 1 and i == j:
        dig = False
        break
    i += 1
    j -= 1
    for y in x:
        s.add(y)
    if len(s) != 2:
        dig = False
        break

if dig and len(s) == 2:
    print("YES")

else:
    print("NO")


n = int(input())
l = []
for _ in range(n):
    l.append(list(input()))

s = set()
i, j = 0, n-1
dig = True
p = l[0][0]
for x in l:
    if x[i] != x[j] or x[i] != p:
        dig = False
        break
    if l.count(p) != 2 and i != j:
        dig = False
        break
    elif l.count(p) != 1 and i == j:
        dig = False
        break
    i += 1
    j -= 1
    for y in x:
        s.add(y)
    if len(s) != 2:
        dig = False
        break

if dig and len(s) == 2:
    print("YES")

else:
    print("NO")


n = int(input())
l = []
for _ in range(n):
    l.append(list(input()))

s = set()
i, j = 0, n-1
dig = True
p = l[0][0]
for x in l:
    if x[i] != x[j] or x[i] != p:
        dig = False
        break
    if x.count(p) != 2 and i != j:
        dig = False
        break
    elif x.count(p) != 1 and i == j:
        dig = False
        break
    i += 1
    j -= 1
    for y in x:
        s.add(y)
    if len(s) != 2:
        dig = False
        break

if dig and len(s) == 2:
    print("YES")

else:
    print("NO")


n = int(input())
l = []
for _ in range(n):
    l.append(list(input()))

s = set()
i, j = 0, -1
dig = True
p = l[0][0]
for x in l:
    if x[i] != x[j] or x[i] == p:
        dig = False
        break

    i += 1
    j -= 1
    for y in x:
        s.add(y)
    if len(s) != 2:
        dig = False
        break

if dig and len(s) == 2:
    print("YES")

else:
    print("NO")


n = int(input())
l = []
for _ in range(n):
    l.append(list(input()))

s = set()
i, j = 0, -1
dig = True
for x in l:
    if x[i] != x[j]:
        dig = False
        break

    i += 1
    j -= 1
    for y in x:
        s.add(y)
    if len(s) != 2:
        dig = False
        break

if dig and len(s) == 2:
    print("YES")

else:
    print("NO")


n = int(input())
l = []
for _ in range(n):
    l.append(list(input()))

s = set()
i, j = 0, -1
dig = True
p = l[0][0]
for x in l:
    if x[i] != x[j] or x[i] != p:
        dig = False
        break

    i += 1
    j -= 1
    for y in x:
        s.add(y)
    if len(s) != 2:
        dig = False
        break

if dig and len(s) == 2:
    print("YES")

else:
    print("NO")


def main():
    n = int(input())
    i = 0
    j = n - 1
    c = None
    c2 = None
    flipped = False
    for i in range(n):
        l = list(input())
        if c == None:
            c = l[1]
        for k in range(n):
            if k != i and k != j:
                if l[k] != c:
                    return False
        if c2 == None:
            c2 = l[i]
        if c2 == c:
            return False
        if l[i] != l[j] or l[i] != c2:
            return False
        i += 1
        j -= 1
    return True

print("YES" if main() else "NO")


def main():
    n = int(input())
    i = 0
    j = n - 1
    c = None
    c2 = None
    flipped = False
    for i in range(n):
        l = list(input())
        if c == None:
            c = l[1]
        else:
            for k in range(n):
                if k != i and k != j:
                    if l[k] != c:
                        return False
        if c2 == None:
            c2 = l[i]
        if c2 == c:
            return False
        if l[i] != l[j] or l[i] != c2:
            return False
        i += 1
        j -= 1
    return True

print("YES" if main() else "NO")


def main():
    n = int(input())
    i = 0
    j = n - 1
    c = None
    c2 = None
    flipped = False
    for i in range(n):
        l = list(input())
        if c == None:
            c = l[1]
        else:
            for k in range(n):
                if k != i and k != j:
                    if l[k] != c:
                        return False
        if c2 == None:
            c2 = l[i]
        if l[i] != l[j] or l[i] != c2:
            return False
        i += 1
        j -= 1
    return True

print("YES" if main() else "NO")


def main():
    n = int(input())
    i = 0
    j = n - 1
    c = None
    c2 = None
    flipped = False
    for i in range(n):
        l = list(input())
        if l[0] == l[1]:
            return False
        if c == None:
            c = l[1]
        else:
            for k in range(n):
                if k != i and k != j:
                    if l[k] != c:
                        return False
        if c2 == None:
            c2 = l[i]
        if l[i] != l[j] or l[i] != c2:
            return False
        i += 1
        j -= 1
    return True

print("YES" if main() else "NO")


def main():
    n = int(input())
    i = 0
    j = n - 1
    c = None
    flipped = False
    for i in range(n):
        l = list(input())
        if c == None:
            c = l[1]
            if l[0] == l[1]:
                return False
        else:
            for k in range(n):
                if k != i and k != j:
                    if l[k] != c:
                        return False
        if l[i] != l[j]:
            return False
        i += 1
        j -= 1
    return True

print("YES" if main() else "NO")


n=int(input())
words=list()
sets=list()
sett=list()
i=0
while i<n:
    word=input()
    w=list(word)
    s=set(w)
    if len(sett)==0 and len(s)==2:
        sett.append(s)
    elif len(s)==2 and (s==sett[-1] or s==sett[0] or s in sett):
        sets.append(len(s))
        sett.append(s)
        words.append(word)
    i+=1
if len(sets)<n:
    print("NO")
else:
    length=len(words)
    k=int(length/2)
    l=-1
    j=0
    for t in words:
        if t[j]!=t[l]:
            print("NO")
            break
        j+=1
        l-=1
        if k==j:
            if (words[0:k]==words[-1:-k-1:-1] or words[0:k]==words[k+1:]) and words[k][0:int(len(words[k])/2)]==words[k][int(len(words[k])/2)+1:]:
                print("YES")
            else:
                print("NO")


n=int(input())
words=list()
sets=list()
i=0
while i<n:
    word=input()
    w=list(word)
    s=set(w)
    if len(s)==2:
        sets.append(len(s))
        words.append(word)
    i+=1
if len(sets)<n:
    print("NO")
else:
    length=len(words)
    k=int(length/2)
    l=-1
    j=0
    for t in words:
        if t[j]!=t[l]:
            print("NO")
            break
        elif k==j:
            if t[k] != words[0][0]:
                print("NO")
                break
            elif (words[0:k]==words[-1:-k-1:-1] or words[0:k]==words[k+1:]) and words[k][0:int(len(words[k])/2)]==words[k][int(len(words[k])/2)+1:]:
                print("YES")
            else:
                print("NO")
        j += 1
        l -= 1


n=int(input())
words=list()
sets=list()
i=0
while i<n:
    word=input()
    w=list(word)
    s=set(w)
    if len(s)==2:
        sets.append(len(s))
        words.append(word)
    i+=1
if len(sets)<n:
    print("NO")
else:
    length=len(words)
    k=int(length/2)
    l=-1
    j=0
    for t in words:
        if t[j]!=t[l]:
            print("NO")
            break
        elif k==j:
            if t[k] != words[0][0]:
                print("NO")
            elif (words[0:k]==words[-1:-k-1:-1] or words[0:k]==words[k+1:]) and words[k][0:int(len(words[k])/2)]==words[k][int(len(words[k])/2)+1:]:
                print("YES")
            else:
                print("NO")
                break
        j += 1
        l -= 1


n=int(input())
words=list()
sets=list()
i=0
while i<n:
    word=input()
    w=list(word)
    s=set(w)
    if len(s)==2:
        sets.append(len(s))
        words.append(word)
    i+=1
if len(sets)<n:
    print("NO")
else:
    length=len(words)
    k=int(length/2)
    l=-1
    j=0
    for t in words:
        if t[j]!=t[l]:
            print("NO")
            break
        j+=1
        l-=1
        if k==j:
            if words[0:k]==words[-1:-k-1:-1] or words[0:k]==words[k+1:]:
                print("YES")
                break


n=int(input())
words=list()
sets=list()
i=0
while i<n:
    word=input()
    w=list(word)
    s=set(w)
    if len(s)==2:
        sets.append(len(s))
        words.append(word)
    i+=1
if len(sets)<n:
    print("NO")
else:
    length=len(words)
    k=int(length/2)
    l=-1
    j=0
    for t in words:
        if t[j]!=t[l]:
            print("NO")
            break
        j+=1
        l-=1
        if k==j:
            if (words[0:k]==words[-1:-k-1:-1] or words[0:k]==words[k+1:]) and words[k][0:int(len(words[k])/2)]==words[k][int(len(words[k])/2)+1]:
                print("YES")
            else:
                print("NO")


n=int(input())
words=list()
i=0
while i<n:
    word=input()
    w=list(word)
    s=set(w)
    if len(s)>2:
        print("NO")
        break
    else:
        words.append(word)
    i+=1
length=len(words)
k=int(length/2)
l=-1
j=0
for t in words:
    if t[j]!=t[l]:
        print("NO")
        break
    j+=1
    l-=1
    if k==j:
        if words[0:k]==words[k+1:]:
            print("YES")
            break


n=int(input())
words=list()
sets=list()
i=0
while i<n:
    word=input()
    w=list(word)
    s=set(w)
    if len(s)>2:
        sets.append(len(s))
    else:
        words.append(word)
    i+=1

if len(sets)<n and len(sets)!=0:
    print("NO")
else:
    length=len(words)
    k=int(length/2)
    l=-1
    j=0
    for t in words:
        if t[j]!=t[l]:
            print("NO")
            break
        j+=1
        l-=1
        if k==j:
            if words[0:k]==words[-1:-k-1:-1]:
                print("YES")
                break


n=int(input())
words=list()
sets=list()
i=0
while i<n:
    word=input()
    w=list(word)
    s=set(w)
    if len(s)==2:
        sets.append(len(s))
        words.append(word)
    i+=1
if len(sets)<n:
    print("NO")
else:
    length=len(words)
    k=int(length/2)
    l=-1
    j=0
    for t in words:
        if t[j]!=t[l]:
            print("NO")
            break
        j+=1
        l-=1
        if k==j:
            if (words[0:k]==words[-1:-k-1:-1] or words[0:k]==words[k+1:]) and words[k][0:int(len(words[k])/2)]==words[k][int(len(words[k])/2)+1:]:
                print("YES")
            else:
                print("NO")


n=int(input())
words=list()
sets=list()
i=0
while i<n:
    word=input()
    w=list(word)
    s=set(w)
    if len(s)==2:
        sets.append(len(s))
        words.append(word)
    i+=1
if len(sets)<n:
    print("NO")
else:
    length=len(words)
    k=int(length/2)
    l=-1
    j=0
    for t in words:
        if t[j]!=t[l]:
            print("NO")
            break
        j+=1
        l-=1
        if k==j:
            if words[0:k]==words[-1:-k-1:-1]:
                print("YES")
                break


n=int(input())
words=list()
i=0
while i<n:
    word=input()
    w=list(word)
    s=set(w)
    if len(s)>2:
        print("\nNO")
        break
    else:
        words.append(word)
    i+=1
length=len(words)
k=int(length/2)
l=-1
j=0
for t in words:
    if t[j]!=t[l]:
        print("NO")
        break
    j+=1
    l-=1
    if k==j:
        if words[0:k]==words[k+1:]:
            print("YES")
            break


n=int(input())
l=[list(input()) for _ in range(n)]
x=l[0][0]
xx=l[0][1]
nn=n//2
for i in range(n):
    s=set(l[i])
    le=len(s)
    if le>2 or le==1: print('NO'); break
    if i==nn:
        if l[i].count(x)>1: print('NO'); break
    if i!=nn:
        if l[i].count(x)>2: print('NO'); break
    for j in s:
        if j!=x and j!=xx: print('NO'); break
    j=i
    if i>nn: j=n-i-1
    if l[i][j]!=x or l[i][-j-1]!=x: print('NO'); break
else: print('YES')


n=int(input())
l=[list(input()) for _ in range(n)]
x=l[0][0]
nn=n//2
for i in range(n):
    le=len(set(l[i]))
    if le>2 or le==1: print('NO'); break
    j=i
    if len(set(l[i][:j]))>1 or len(set(l[i][j+1:-j-1]))>1 or len(set(l[i][-j:]))>1: print('NO'); break
    if i>n//2: j=n-i-1
    if l[i][j]!=x or l[i][-j-1]!=x: print('NO'); break
else: print('YES')


from sys import *
n=int(input())
l=[list(input()) for _ in range(n)]
x=l[0][0]
xx=l[0][1]
nn=n//2
for i in range(n):
    s=set(l[i])
    le=len(s)
    if le>2 or le==1: print('NO'); break
    if i==nn:
        if l[i].count(x)>1: print('NO'); break
    if i!=nn:
        if l[i].count(x)>2: print('NO'); break
    for j in s:
        if j!=x and j!=xx: print('NO'); exit()
    j=i
    if i>nn: j=n-i-1
    if l[i][j]!=x or l[i][-j-1]!=x: print('NO'); break
else: print('YES')


n=int(input())
l=[list(input()) for _ in range(n)]
x=l[0][0]
nn=n//2
for i in range(n):
    le=len(set(l[i]))
    if le>2 or le==1: print('NO'); break
    if i==nn:
        if l[i].count(x)>1: print('NO'); break
    if i!=nn:
        if l[i].count(x)>2: print('NO'); break
    j=i
    if i>nn: j=n-i-1
    if l[i][j]!=x or l[i][-j-1]!=x: print('NO'); break
else: print('YES')


n=int(input())
l=[list(input()) for _ in range(n)]
x=l[0][0]
for i in range(n):
    if len(set(l[i]))>2: print('NO'); break
    j=i
    if i>n//2: j=n-i-1
    if l[i][j]!=x or l[i][-j-1]!=x: print('NO'); break
else: print('YES')


from sys import *
n=int(input())
l=[list(input()) for _ in range(n)]
x=l[0][0]
xx=l[0][1]
nn=n//2
for i in range(n):
    s=set(l[i])
    le=len(s)
    if le>2 or le==1: print('NO'); break
    if i==nn:
        if l[i].count(x)>1: print('NO'); break
    if i!=nn:
        if l[i].count(x)>2: print('NO'); break
    for j in s:
        if j!=x and j!=xx: print('NO'); exit()
    j=i
    if i>nn: j=n-i-1
    if l[i][j]!=x or l[i][-j-1]!=x: print('NO'); break
else: print('YES


n=int(input())
l=[list(input()) for _ in range(n)]
x=l[0][0]
for i in range(n):
    le=len(set(l[i]))
    if le>2 or le==1: print('NO'); break
    j=i
    if i>n//2: j=n-i-1
    if l[i][j]!=x or l[i][-j-1]!=x: print('NO'); break
else: print('YES')


hat = int(input())
lst = []
check = ""
for i in range(hat):
    inp = input()
    check += inp
    if len(set(check)) != 2:
        print("NO")
        quit()
    else:
        lst.append(inp)

char = lst[0][0]
length = 0
for i in check:
    if i == char:
        length += 1
if length != 2*hat-1:
    print("NO")
    quit()
score = 0
for i in range(hat):
    if lst[i][i] != char or lst[i][hat-i-1] != char:
        break
    else:
        score += 1
        continue

if score == hat:
    print("YES")
else:
    print("NO")


hat = int(input())
lst = []
check = ""
for i in range(hat):
    inp = input()
    check += inp
    if len(set(check)) > 2:
        print("NO")
        quit()
    else:
        lst.append(inp)

char = lst[0][0]
score = 0
for i in range(hat):
    if lst[i][i] != char or lst[i][hat-i-1] != char:
        break
    else:
        score += 1
        continue

if score == hat:
    print("YES")
else:
    print("NO")


hat = int(input())
lst = []
check = ""
for i in range(hat):
    inp = input()
    check += inp
    if len(set(check)) != 2:
        print("NO")
        quit()
    else:
        lst.append(inp)

char = lst[0][0]
score = 0
for i in range(hat):
    if lst[i][i] != char or lst[i][hat-i-1] != char:
        break
    else:
        score += 1
        continue

if score == hat:
    print("YES")
else:
    print("NO")


hat = int(input())
lst = []
check = ""
for i in range(hat):
    inp = input()
    check += inp
    if len(set(check)) > 2:
        print("NO")
        quit()
    else:
        lst.append(inp)

char = lst[0][0]
score = 0
for i in range(hat):
    print(lst[i][i],char,lst[i][hat-i-1])
    if lst[i][i] != char or lst[i][hat-i-1] != char:
        break
    else:
        score += 1
        continue

if score == hat:
    print("YES")
else:
    print("NO")


n=int(input())
L=[input() for k in range(n)]
D=L[0][0]
E=L[0][1]
for k in range(n):
    for j in range(n):
        if(k==j):
            if(D!=L[k][j]):
                print("NO")
                exit()
        else:
            if(k==abs(n-1-j)):
                if(D!=L[k][j]):
                    print("NO")
                    exit()
            else:
                if(L[k][j]!=D and L[k][j]!=E):
                    print("NO")
                    exit()
print("YES")


n=int(input())
L=[input() for k in range(n)]
D=L[0][0]
E=L[0][1]
for k in range(n):
    for j in range(n):
        if(k==j):
            if(D!=L[k][j]):
                print("NO")
                exit()
        else:
            if(k==abs(n-1-j)):
                if(D!=L[k][j]):
                    print("NO")
                    exit()
            else:
                if(L[k][j]==E):
                    print("NO")
                    exit()
                else:
                    if(L[k][j]!=E):
                        print("NO")
                        exit()
print("YES")


n=int(input())
L=[input() for k in range(n)]
D=L[0][0]
E=L[0][1]
for k in range(n):
    for j in range(n):
        if(k==j):
            if(D!=L[k][j]):
                print("NO")
                exit()
        else:
            if(k==abs(n-1-j)):
                if(D!=L[k][j]):
                    print("NO")
                    exit()
            else:
                if(D==E):
                    print("NO")
                    exit()
                else:
                    if(L[k][j]!=D and L[k][j]!=E):
                        print("NO")
                        exit()
print("YES")


n=int(input())
L=[input() for k in range(n)]
D=L[0][0]
E=L[0][1]
for k in range(n):
    for j in range(n):
        if(k==j):
            if(D!=L[k][j]):
                print("NO")
                exit()
        else:
            if(k==abs(n-1-j)):
                if(D!=L[k][j]):
                    print("NO")
                    exit()
            else:
                if(L[k][j]==D):
                    print("NO")
                    exit()
                else:
                    if(L[k][j]!=E):
                        print("NO")
                        exit()
print("YES")


#57
l=[]
a=int(input())
for i in range(a):
    z=input()
    if len(set(z)) >2:
        print('no')
        break
    else:
        l.append(z)
p=l[0][0]
c=0
for i in range(a):
    if l[i][i]==p and l[a-i-1][a-i-1]==p:
        c+=1
if c==a:
    print('yes')
else:
    print("no")


#57
l=[]
a=int(input())
for i in range(a):
    l.append(input())

p=l[0][0]
c=0
u=''
for i in range(a):
    if l[i][i]==p and l[i][a-i-1]==p:
        c+=1
    if l[i].count(p)>2:
        c-=1
    if l[a//2].count(p)>1:
        c-=1
    u=u+l[i]

if c==a and len(set(u)) <3:
    print('YES')
else:
    print("NO")


#57
l=[]
k=0
a=int(input())
for i in range(a):
    z=input()
    if len(set(z)) >2:
        print('NO')
        k=1
        break
    else:
        l.append(z)

if k ==0:
    p=l[0][0]
    c=0
    for i in range(a):
        if l[i][i]==p and l[a-i-1][a-i-1]==p:
            c+=1
    if c==a:
        print('YES')
    else:
        print("NO")


#57
l=[]
k=0
a=int(input())
for i in range(a):
    z=input()
    if len(set(z)) !=2   :
        print('NO')
        k=1
        break
    else:
        l.append(z)

if k ==0:
    p=l[0][0]
    c=0
    for i in range(a):
        if l[i][i]==p and l[a-i-1][a-i-1]==p:
            c+=1
        if l[i].count(p)>2:
            c-=1
    if c==a:
        print('YES')
    else:
        print("NO")


#57
l=[]
k=0
a=int(input())
for i in range(a):
    z=input()
    if len(set(z)) !=2   :
        print('NO')
        k=1
        break
    else:
        l.append(z)

if k ==0:
    p=l[0][0]
    c=0
    for i in range(a):
        if l[i][i]==p and l[i][a-i-1]==p:
            c+=1
        if l[i].count(p)>2:
            c-=1
        if l[a//2].count(p)>1:
            c-=1
    if c==a:
        print('YES')
    else:
        print("NO")


#57
l=[]
k=0
a=int(input())
for i in range(a):
    z=input()
    if len(set(z)) >2:
        print('no')
        k=1
        break
    else:
        l.append(z)

if k ==0:
    p=l[0][0]
    c=0
    for i in range(a):
        if l[i][i]==p and l[a-i-1][a-i-1]==p:
            c+=1
    if c==a:
        print('yes')
    else:
        print("no")


#57
l=[]
k=0
a=int(input())
for i in range(a):
    z=input()
    if len(set(z)) !=2  :
        print('NO')
        k=1
        break
    else:
        l.append(z)

if k ==0:
    p=l[0][0]
    c=0
    for i in range(a):
        if l[i][i]==p and l[a-i-1][a-i-1]==p:
            c+=1
    if c==a:
        print('YES')
    else:
        print("NO")


#57
l=[]
k=0
a=int(input())
for i in range(a):
    z=input()
    if len(set(z)) !=2   :
        print('NO')
        k=1
        break
    else:
        l.append(z)

if k ==0:
    p=l[0][0]
    c=0
    u=''
    for i in range(a):
        if l[i][i]==p and l[i][a-i-1]==p:
            c+=1
        if l[i].count(p)>2:
            c-=1
        if l[a//2].count(p)>1:
            c-=1
        u=u+l[i]

    if c==a and len(set(u)) <3:
        print('YES')
    else:
        print("NO")


#57
l=[]
k=0
a=int(input())
for i in range(a):
    z=input()
    if len(set(z)) !=2   :
        print('NO')
        k=1
        break
    else:
        l.append(z)

if k ==0:
    p=l[0][0]
    c=0
    for i in range(a):
        if l[i][i]==p and l[a-i-1][a-i-1]==p:
            c+=1
        if l[i].count(p)>2:
            c-=1
        if l[a//2].count(p)>1:
            c-=1
    if c==a:
        print('YES')
    else:
        print("NO")


#57
l=[]
k=0
a=int(input())
for i in range(a):
    z=input()
    if len(set(z)) !=2   :
        print('NO')
        k=1
        break
    else:
        l.append(z)

if k ==0:
    p=l[0][0]
    c=0
    for i in range(a):
        if l[i][i]==p and l[a-i-1][a-i-1]==p:
            c+=1
        if l[i].count(p)>2:
            c-=1
    print(l)
    if c==a:
        print('YES')
    else:
        print("NO")


n=int(input().strip())
arr=[[j for j in input().strip()] for i in range(n)]
diagonal,other=[],[]
for i in range(n):
    for j in range(n):
        if i==j or (i+j)==(n-1):
            if arr[i][j] not in diagonal:
                diagonal.append(arr[i][j])
        else:
            if arr[i][j] not in other:
                other.append(arr[i][j])
if len(diagonal)==1 and len(other)==1 :
    if "".join(diagonal)!="".join(other):
        print("YES")
    else:
        print("NO")
else:
    print("NO")


n=int(input().strip())
arr=[[j for j in input().strip()] for i in range(n)]
flag=0
x=arr[0][0]
for i in range(n):
    if arr[i][i]!=x or arr[i][n-1-i]!=x:
        flag=1
        break
x=arr[0][1]
for i in range(n):
    for j in range(n):
        if i==j or j==n-1-i:
            continue
        if arr[i][j]!=x:
            flag=1
            break
if flag==0:
    print("YES")
elif flag==1 or x==arr[0][1]:
    print("NO")
else:
    print("NO")


n=int(input().strip())
arr=[[j for j in input().strip()] for i in range(n)]
diagonal,other=[],[]
for i in range(n):
    for j in range(n):
        if i==j or (i+j)==(n-1):
            if arr[i][j] not in diagonal:
                diagonal.append(arr[i][j])
        else:
            if arr[i][j] not in other:
                other.append(arr[i][j])
if len(diagonal)==1 and len(other)==1 :
    if diagonal[1]!=other[1]:
        print("YES")
    else:
        print("NO")
else:
    print("NO")


n=int(input().strip())
arr=[[j for j in input().strip()] for i in range(n)]
diagonal,other=[],[]
for i in range(n):
    for j in range(n):
        if i==j or (i+j)==(n-1):
            if arr[i][j] not in diagonal:
                diagonal.append(arr[i][j])
        else:
            if arr[i][j] not in other:
                other.append(arr[i][j])
if len(diagonal)==1 and len(other)==1:
    print("YES")
else:
    print("NO")


n=int(input().strip())
arr=[[j for j in input().strip()] for i in range(n)]
diagonal,other=[],[]
for i in range(n):
    for j in range(n):
        if i==j or (i+j)==(n-1):
            if arr[i][j] not in diagonal:
                diagonal.append(arr[i][j])
        else:
            if arr[i][j] not in other:
                other.append(arr[i][j])
if len(diagonal)==1 and len(other)==1 and diagonal[1]!=other[1]:
    print("YES")
else:
    print("NO")


n = int(input())
out = True
for i in range(n):
    x = input()
    a = list(set(list(x)))
    if len(a)==2:
    	if i==n//2:
    		if x.count(a[0])==1:
    			if x[i]!=a[0]:
    				out = False
    		elif x.count(a[1])==1:
    			if x[i]!=a[1]:
    				out = False
    		else:
    			out = False
    	else:
	        if x.count(a[0])==2:
	            if x[i]!=a[0] or x[-1-i]!=a[0]:
	            	out = False
	        elif x.count(a[1])==2:
	            if x[i]!=a[1] or x[-1-i]!=a[1]:
	                out = False
	        else:
	            out = False
    else:
        out = False
if out:
    print("YES")
else:
    print("NO")


n = int(input())
out = True
letters = []
for i in range(n):
    x = input()
    a = list(set(list(x)))
    if len(a)==2:
    	if len(letters)==0:
    		letters = [a[0],a[1]]
    	if a[0] not in letters or a[1] not in letters:
    		out = False
    	else:
	    	if i==n//2:
	    		if x.count(a[0])==1:
	    			if x[i]!=a[0]:
	    				out = False
	    		elif x.count(a[1])==1:
	    			if x[i]!=a[1]:
	    				out = False
	    		else:
	    			out = False
	    	else:
		        if x.count(a[0])==2:
		            if x[i]!=a[0] or x[-1-i]!=a[0]:
		            	out = False
		        elif x.count(a[1])==2:
		            if x[i]!=a[1] or x[-1-i]!=a[1]:
		                out = False
		        else:
		            out = False
    if len(a)!=2:
    	out = False
if out:
    print("YES")
else:
    print("NO")


n = int(input())
out = True
letters = []
for i in range(n):
    x = input()
    a = list(set(list(x)))
    if len(letters)==0:
    	letters = [a[0],a[1]]
    if len(a)==2:
        if a[0] not in letters or a[1] not in letters:
            out = False
    	else:
	    	if i==n//2:
	    		if x.count(a[0])==1:
	    			if x[i]!=a[0]:
	    				out = False
	    		elif x.count(a[1])==1:
	    			if x[i]!=a[1]:
	    				out = False
	    		else:
	    			out = False
	    	else:
		        if x.count(a[0])==2:
		            if x[i]!=a[0] or x[-1-i]!=a[0]:
		            	out = False
		        elif x.count(a[1])==2:
		            if x[i]!=a[1] or x[-1-i]!=a[1]:
		                out = False
		        else:
		            out = False
    else:
        out = False
if out:
    print("YES")
else:
    print("NO")


n = int(input())
out = True
letters = []
for i in range(n):
    x = input()
    a = list(set(list(x)))
    if len(letters)==0:
    	letters = [a[0],a[1]]
    if len(a)==2:
    	if a[0] in letters and a[1] in letters:
	    	if i==n//2:
	    		if x.count(a[0])==1:
	    			if x[i]!=a[0]:
	    				out = False
	    		elif x.count(a[1])==1:
	    			if x[i]!=a[1]:
	    				out = False
	    		else:
	    			out = False
	    	else:
		        if x.count(a[0])==2:
		            if x[i]!=a[0] or x[-1-i]!=a[0]:
		            	out = False
		        elif x.count(a[1])==2:
		            if x[i]!=a[1] or x[-1-i]!=a[1]:
		                out = False
		        else:
		            out = False
		else:
			out = False
    else:
        out = False
if out:
    print("YES")
else:
    print("NO")


n = int(input())
out = True
for i in range(n):
    x = input()
    a = list(set(list(x)))
    if len(a)==2:
        if x.count(a[0])==2:
            if i==n//2:
                if x[i]!=a[0]:
                    out = False
            else:
                if x[i]!=a[0] or x[-1-i]!=a[0]:
                    out = False
        elif x.count(a[1])==2:
            if i==n//2:
                if x[i]!=a[1]:
                    out = False
            else:
                if x[i]!=a[1] or x[-1-i]!=a[1]:
                    out = False
        else:
            out = False
    else:
        out = False
if out:
    print("YES")
else:
    print("NO")


n = int(input())
out = True
for i in range(n):
    x = input()
    a = list(set(list(x)))
    if len(a)==2:
        if x.count(a[0])==2:
            if i==n//2:
                if x[i]!=a[0]:
                    out = False
            else:
                if x[i]!=a[0] or x[-1-i]!=a[0]:
                    out = False
        elif x.count(a[1])==2:
            if i==n//2:
                if x[i]!=a[0]:
                    out = False
            else:
                if x[i]!=a[1] or x[-1-i]!=a[1]:
                    out = False
        else:
            out = False
    else:
        out = False
if out:
    print("YES")
else:
    print("NO")


n=int(input())
c=[0]*26
a=[]
for i in range(n):
    a.append(input().strip())
    for k in a[-1]:
        c[ord(k)-ord('a')]+=1
b=True
for i in range(n):
    if a[i][i]!=a[0][0] or a[0][0]!=a[i][n-i-1]:
        b=False
        break
if b==False:
    print('NO')
elif a[0][0]==a[0][1]:
    print('NO')
elif c[ord(a[0][1])-ord('a')]!=n*n-2*n+1:
    print('NO')
else:
    print('YES')


n = int(input())
a = [list(str(a) for a in input().split()) for i in range(n)]
k = []
l = []
l1 = []
for i in a:
     k.append(list((i[0])))
for i in range(len(k)):
     l.append(k[i][i])
     l.append(k[i][len(k) - 1 - i])
for i in k:
     for j in i:
          if j == l[0]:
               i.remove(j)
for i in k:
     for j in i:
          if j not in l1:
               l1.append(j)
if l.count(l[0]) == n * 2:
     if len(l1)==1:
          if l[0]!=l1[0]:
           print('YES')
          else:print('NO')
     else:
          print('NO')
else:
     print('NO')


n=int(input())
a=[list(str(a) for a in input().split()) for i in range(n)]
k=[]
l=[]
l1=[]
for i in a:
     k.append(list((i[0])))
for i in range(len(k)):
     l.append(k[i][i])
     l.append(k[i][len(k)-1-i])
for i in k:
     for j in i:
          if j==l[0]:
               i.remove(j)
for i in k:
     for j in i:
          if j not in l1:
               l1.append(j)
if l.count(l[0])==n*2:
     if len(l1)==1:
      print('YES')
     else:print('NO')
else:print('NO')


n = int(input())
arr = []
for i in range(n):
    arr.append(input())
d,nd = arr[0][0],arr[0][1]
if d==nd:
    print('NO')
else:
    check = 0
    index = n//2
    for i in range(n):
        for j in range(index+1):
            if i==j or i+j==n-1:
                if arr[i][j]==arr[i][n-1-j]==d:
                    continue
                else:
                    check = 1
                    break
            else:
                if arr[i][j] != nd:
                    check = 1
                    break
        if check==1:
            break
    if check==0:
        print('YES')
    else:
        print('NO')


n = int(input())
arr = []
for i in range(n):
    arr.append(input())
d,nd = arr[0][0],arr[0][1]
if d==nd:
    print('NO')
else:
    check = 0
    index = n//2
    for i in range(n):
        for j in range(index+1):
            if i==j or i+j==n-1:
                if arr[i][j]==arr[i][n-1-j]==d:
                    continue
                else:
                    check = 1
                    break
            else:
                if arr[i][j] != nd or arr[i][n-1-j] != nd:
                    check = 1
                    break
        if check==1:
            break
    if check==0:
        print('YES')
    else:
        print('NO')


#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 30;
int a[maxn];

int mex(vi v) {
    forn(i, v.size() + 1) a[i] = 0;
    for (int x: v) a[x] = 1;
    int z = 0;
    while (a[z]) ++z;
    return z;
}

map<int, int> memo_gr;

int gr(int m) {
    if (memo_gr.count(m)) return memo_gr[m];
//    cout << m << '\n';
    vi v;
    for1(i, maxn) {
        if (m < (1 << (i - 1))) break;
//        int mm = m & ((1 << (i - 1)) - 1) | (m >> i);
        v.pb(gr((m & ((1 << (i - 1)) - 1)) | (m >> i)));
    }
    return memo_gr[m] = mex(v);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n;
    map<int, int> masks;
    forn(i, n) {
        int x;
        cin >> x;
        for (int p = 2; p * p <= x; ++p) {
            if (x % p) continue;
            int z = 0;
            while (x % p == 0) x /= p, ++z;
            masks[p] |= z;
        }
        if (x > 1) masks[x] |= 1;
    }
    int ans = 0;
    for (auto w: masks) {
//        cerr << w.fi << ' ' << w.se << ' ' << gr(w.se) << '\n';
        ans ^= gr(w.se);
    }
    cout << (ans > 0 ? "Mojtaba" : "Arpa") << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 31;
int a[maxn];

int mex(vi v) {
    forn(i, v.size() + 1) a[i] = 0;
    for (int x: v) a[x] = 1;
    int z = 0;
    while (a[z]) ++z;
    return z;
}

map<int, int> memo_gr;

int gr(int m) {
    if (memo_gr.count(m)) return memo_gr[m];
//    cout << m << '\n';
    vi v;
    for1(i, maxn) {
        if (m < (1 << (i - 1))) break;
//        int mm = m & ((1 << (i - 1)) - 1) | (m >> i);
        v.pb(gr((m & ((1 << (i - 1)) - 1)) | (m >> i)));
    }
    return memo_gr[m] = mex(v);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n;
    map<int, int> masks;
    forn(i, n) {
        int x;
        cin >> x;
        for (int p = 2; p * p <= x; ++p) {
            if (x % p) continue;
            int z = 0;
            while (x % p == 0) x /= p, ++z;
            masks[p] |= 1 << z;
        }
        if (x > 1) masks[x] |= 1;
    }
    int ans = 0;
    for (auto w: masks) {
//        cerr << w.fi << ' ' << w.se << ' ' << gr(w.se) << '\n';
        ans ^= gr(w.se);
    }
    cout << (ans > 0 ? "Mojtaba" : "Arpa") << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 31;
int a[maxn];

int mex(vi v) {
    forn(i, v.size() + 1) a[i] = 0;
    for (int x: v) a[x] = 1;
    int z = 0;
    while (a[z]) ++z;
    return z;
}

map<int, int> memo_gr;

int gr(int m) {
    if (memo_gr.count(m)) return memo_gr[m];
//    cout << m << '\n';
    vi v;
    for1(i, maxn) {
        if (m < (1 << (i - 1))) break;
//        int mm = m & ((1 << (i - 1)) - 1) | (m >> i);
        v.pb(gr((m & ((1 << (i - 1)) - 1)) | (m >> i)));
    }
    return memo_gr[m] = mex(v);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n;
    map<int, int> masks;
    forn(i, n) {
        int x;
        cin >> x;
        for (int p = 2; p * p <= x; ++p) {
            if (x % p) continue;
            int z = 0;
            while (x % p == 0) x /= p, ++z;
            masks[p] |= 1 << (z - 1);
        }
        if (x > 1) masks[x] |= 1;
    }
    int ans = 0;
    for (auto w: masks) {
//        cerr << w.fi << ' ' << w.se << ' ' << gr(w.se) << '\n';
        ans ^= gr(w.se);
    }
    cout << (ans > 0 ? "Mojtaba" : "Arpa") << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


#if defined(LOCAL)
#define PROBLEM_NAME "C"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

const l MAX_PRIME = 50000;
// returns v[i] = smallest prime divisor of i or 1
vl sieve_primes(vl& primes) {
  vl next_div(MAX_PRIME, 1);
  for (l i = 2; i < MAX_PRIME; i++) {
    if (next_div[i] != 1) continue;
    primes.emplace_back(i);
    for (l j = i; j < MAX_PRIME; j += i) if (next_div[j] == 1) next_div[j] = i;
  }
  return next_div;
}

// in asc order
vl factorize_to_primes(l n, vl& primes, vl& next_div) {
  auto p = primes.begin();
  vl result;
  while (n >= MAX_PRIME and p != primes.end()) {
    while (n % *p == 0) { result.emplace_back(*p); n /= *p; }
    p++;
  }
  if (n >= MAX_PRIME) {
    result.emplace_back(n);
    n = 1;
  }
  while (n != 1) {
    result.emplace_back(next_div[n]);
    n /= next_div[n];
  }
  return result;
}

mll score;

l get_score(l m) {
  if (score.count(m)) return score[m];
  bool one = false, two = false;
  l i = 1, j = 1;
  while (j <= m) {
    if (j & m) {
      l t = ((j - 1) & m) | (m >> i);
      l s = get_score(t);
      if (s == 0) {
        return score[m] = 3;
      }
      if (s == 1) two = true;
      if (s == 2) one = true;
    }
    i++; j = j << 1;
  }
  if (one and two) return score[m] = 3;
  if (one) return score[m] = 1;
  if (two) return score[m] = 2;
  return score[m] = 0;
}

void solve(istream& cin, ostream& cout) {
  score[0] = 2;
  l n; cin >> n;
  vl v(n); F(i, 0, n) cin >> v[i];
  vl primes; vl next_div = sieve_primes(primes);
  unordered_map<l, set<l>> u;
  for (auto x : v) {
    auto ff = factorize_to_primes(x, primes, next_div);
    l prev = 0;
    l c = 0;
    for (auto f : ff) {
      if (f != prev and prev) {
        u[prev].emplace(c);
        c = 0;
      }
      c++;
      prev = f;
    }
    if (prev) u[prev].emplace(c);
  }
  // L(u);
  l oddity = 0, choices = 0, bads = 0;
  for (auto& kv : u) {
    l t = 0;
    for (auto i : kv.second) t += l(1) << i;
    l s = get_score(t);
    if (s == 1) oddity++;
    if (s == 0) oddity++;
    if (s == 3) choices++;
  }
  if (choices) {
    cout << ((choices % 2) ? "Mojtaba" : "Arpa") << lf;
  } else {
    cout << ((oddity % 2) ? "Mojtaba" : "Arpa") << lf;
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


#if defined(LOCAL)
#define PROBLEM_NAME "C"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

const l MAX_PRIME = 50000;
// returns v[i] = smallest prime divisor of i or 1
vl sieve_primes(vl& primes) {
  vl next_div(MAX_PRIME, 1);
  for (l i = 2; i < MAX_PRIME; i++) {
    if (next_div[i] != 1) continue;
    primes.emplace_back(i);
    for (l j = i; j < MAX_PRIME; j += i) if (next_div[j] == 1) next_div[j] = i;
  }
  return next_div;
}

// in asc order
vl factorize_to_primes(l n, vl& primes, vl& next_div) {
  auto p = primes.begin();
  vl result;
  while (n >= MAX_PRIME and p != primes.end()) {
    while (n % *p == 0) { result.emplace_back(*p); n /= *p; }
    p++;
  }
  if (n >= MAX_PRIME) {
    result.emplace_back(n);
    n = 1;
  }
  while (n != 1) {
    result.emplace_back(next_div[n]);
    n /= next_div[n];
  }
  return result;
}

mll score;

l grindy(l m) {
  if (score.count(m)) return score[m];
  unordered_set<l> s;
  l i = 1;
  while (true) {
    l j = l(1) << (i - 1);
    if (j > m) break;
    l t = ((j - 1) & m) | (m >> i);
    s.emplace(grindy(t));
    i++;
  }
  l j = 0;
  while (s.count(j)) j++;
  return score[m] = j;
}

void solve(istream& cin, ostream& cout) {
  score[0] = 0;
  l n; cin >> n;
  vl v(n); F(i, 0, n) cin >> v[i];
  vl primes; vl next_div = sieve_primes(primes);
  unordered_map<l, l> u;
  for (auto x : v) {
    auto ff = factorize_to_primes(x, primes, next_div);
    l prev = 0;
    l c = 0;
    for (auto f : ff) {
      if (f != prev and prev) {
        u[prev] |= 1 << (c - 1);
        c = 0;
      }
      c++;
      prev = f;
    }
    if (prev) u[prev] |= 1 << (c - 1);
  }
  l x = 0;
  for (auto& kv : u) x ^= grindy(kv.second);
  cout << (x ? "Mojtaba" : "Arpa") << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


#if defined(LOCAL)
#define PROBLEM_NAME "C"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

const l MAX_PRIME = 50000;
// returns v[i] = smallest prime divisor of i or 1
vl sieve_primes(vl& primes) {
  vl next_div(MAX_PRIME, 1);
  for (l i = 2; i < MAX_PRIME; i++) {
    if (next_div[i] != 1) continue;
    primes.emplace_back(i);
    for (l j = i; j < MAX_PRIME; j += i) if (next_div[j] == 1) next_div[j] = i;
  }
  return next_div;
}

// in asc order
vl factorize_to_primes(l n, vl& primes, vl& next_div) {
  auto p = primes.begin();
  vl result;
  while (n >= MAX_PRIME and p != primes.end()) {
    while (n % *p == 0) { result.emplace_back(*p); n /= *p; }
    p++;
  }
  if (n >= MAX_PRIME) {
    result.emplace_back(n);
    n = 1;
  }
  while (n != 1) {
    result.emplace_back(next_div[n]);
    n /= next_div[n];
  }
  return result;
}

mll score;

l get_score(l m) {
  if (score.count(m)) return score[m];
  score[m] = 0;
  l i = 1, j = 1;
  while (j <= m) {
    l t = ((j - 1) & m) | (m >> i);
    score[m] = score[m] | (3 - get_score(t));
    if (score[m] == 3) break;
    i++; j = j << 1;
  }
  return score[m];
}

void solve(istream& cin, ostream& cout) {
  score[0] = 2;
  l n; cin >> n;
  vl v(n); F(i, 0, n) cin >> v[i];
  vl primes; vl next_div = sieve_primes(primes);
  unordered_map<l, set<l>> u;
  for (auto x : v) {
    auto ff = factorize_to_primes(x, primes, next_div);
    l prev = 0;
    l c = 0;
    for (auto f : ff) {
      if (f != prev and prev) {
        u[prev].emplace(c);
        c = 0;
      }
      c++;
      prev = f;
    }
    if (prev) u[prev].emplace(c);
  }
  // L(u);
  l oddity = 0, choices = 0;
  for (auto& kv : u) {
    l t = 0;
    for (auto i : kv.second) t += l(1) << (i - 1);
    l s = get_score(t);
    if (s == 1) oddity++;
    // if (s == 0) oddity++;
    if (s == 3) choices++;
  }
  // L(choices, oddity, "co");
  if (choices) {
    cout << ((choices % 2) ? "Mojtaba" : "Arpa") << lf;
  } else {
    cout << ((oddity % 2) ? "Mojtaba" : "Arpa") << lf;
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


#if defined(LOCAL)
#define PROBLEM_NAME "C"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

const l MAX_PRIME = 50000;
// returns v[i] = smallest prime divisor of i or 1
vl sieve_primes(vl& primes) {
  vl next_div(MAX_PRIME, 1);
  for (l i = 2; i < MAX_PRIME; i++) {
    if (next_div[i] != 1) continue;
    primes.emplace_back(i);
    for (l j = i; j < MAX_PRIME; j += i) if (next_div[j] == 1) next_div[j] = i;
  }
  return next_div;
}

// in asc order
vl factorize_to_primes(l n, vl& primes, vl& next_div) {
  auto p = primes.begin();
  vl result;
  while (n >= MAX_PRIME and p != primes.end()) {
    while (n % *p == 0) { result.emplace_back(*p); n /= *p; }
    p++;
  }
  if (n >= MAX_PRIME) {
    result.emplace_back(n);
    n = 1;
  }
  while (n != 1) {
    result.emplace_back(next_div[n]);
    n /= next_div[n];
  }
  return result;
}

void solve(istream& cin, ostream& cout) {
  l n; cin >> n;
  vl v(n); F(i, 0, n) cin >> v[i];
  vl primes; vl next_div = sieve_primes(primes);
  unordered_map<l, set<l>> u;
  for (auto x : v) {
    auto ff = factorize_to_primes(x, primes, next_div);
    l prev = 0;
    l c = 0;
    for (auto f : ff) {
      if (f != prev and prev) {
        u[prev].emplace(c);
        c = 0;
      }
      c++;
      prev = f;
    }
    if (prev) u[prev].emplace(c);
  }
  // L(u);
  l t = 0;
  bool mwin = false;
  for (auto& kv : u) {
    t += kv.second.size();
    if (*kv.second.rbegin() != kv.second.size()) mwin = true;
  }
  cout << ((t % 2 == 1 or mwin) ? "Mojtaba" : "Arpa") << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


#if defined(LOCAL)
#define PROBLEM_NAME "C"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

const l MAX_PRIME = 50000;
// returns v[i] = smallest prime divisor of i or 1
vl sieve_primes(vl& primes) {
  vl next_div(MAX_PRIME, 1);
  for (l i = 2; i < MAX_PRIME; i++) {
    if (next_div[i] != 1) continue;
    primes.emplace_back(i);
    for (l j = i; j < MAX_PRIME; j += i) if (next_div[j] == 1) next_div[j] = i;
  }
  return next_div;
}

// in asc order
vl factorize_to_primes(l n, vl& primes, vl& next_div) {
  auto p = primes.begin();
  vl result;
  while (n >= MAX_PRIME and p != primes.end()) {
    while (n % *p == 0) { result.emplace_back(*p); n /= *p; }
    p++;
  }
  if (n >= MAX_PRIME) {
    result.emplace_back(n);
    n = 1;
  }
  while (n != 1) {
    result.emplace_back(next_div[n]);
    n /= next_div[n];
  }
  return result;
}

mll score;

l get_score(l m) {
  if (score.count(m)) return score[m];
  score[m] = 0;
  l i = 1, j = 1;
  while (j <= m) {
    l t = ((j - 1) & m) | (m >> i);
    score[m] = score[m] | (3 - get_score(t));
    if (score[m] == 3) break;
    i++; j = j << 1;
  }
  return score[m];
}

void solve(istream& cin, ostream& cout) {
  score[0] = 2;
  l n; cin >> n;
  vl v(n); F(i, 0, n) cin >> v[i];
  vl primes; vl next_div = sieve_primes(primes);
  unordered_map<l, set<l>> u;
  for (auto x : v) {
    auto ff = factorize_to_primes(x, primes, next_div);
    l prev = 0;
    l c = 0;
    for (auto f : ff) {
      if (f != prev and prev) {
        u[prev].emplace(c);
        c = 0;
      }
      c++;
      prev = f;
    }
    if (prev) u[prev].emplace(c);
  }
  // L(u);
  l oddity = 0, choices = 0;
  for (auto& kv : u) {
    l t = 0;
    for (auto i : kv.second) t += l(1) << (i - 1);
    l s = get_score(t);
    if (s == 1) oddity++;
    // if (s == 0) oddity++;
    if (s == 3) choices++;
  }
  // L(choices, oddity, "co");
  if (choices % 2) {
    cout << "Mojtaba" << lf;
  } else {
    cout << ((oddity % 2) ? "Mojtaba" : "Arpa") << lf;
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


#if defined(LOCAL)
#define PROBLEM_NAME "C"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

const l MAX_PRIME = 50000;
// returns v[i] = smallest prime divisor of i or 1
vl sieve_primes(vl& primes) {
  vl next_div(MAX_PRIME, 1);
  for (l i = 2; i < MAX_PRIME; i++) {
    if (next_div[i] != 1) continue;
    primes.emplace_back(i);
    for (l j = i; j < MAX_PRIME; j += i) if (next_div[j] == 1) next_div[j] = i;
  }
  return next_div;
}

// in asc order
vl factorize_to_primes(l n, vl& primes, vl& next_div) {
  auto p = primes.begin();
  vl result;
  while (n >= MAX_PRIME and p != primes.end()) {
    while (n % *p == 0) { result.emplace_back(*p); n /= *p; }
    p++;
  }
  if (n >= MAX_PRIME) {
    result.emplace_back(n);
    n = 1;
  }
  while (n != 1) {
    result.emplace_back(next_div[n]);
    n /= next_div[n];
  }
  return result;
}

mll score;

l get_score(l m) {
  if (score.count(m)) return score[m];
  bool one = false, two = false;
  l i = 1, j = 1;
  while (j <= m) {
    if (j & m) {
      l t = ((j - 1) & m) | (m >> i);
      l s = get_score(t);
      if (s == 0) {
        return score[m] = 3;
      }
      if (s == 1) two = true;
      if (s == 2) one = true;
    }
    i++; j = j << 1;
  }
  if (one and two) return score[m] = 3;
  if (one) return score[m] = 1;
  if (two) return score[m] = 2;
  return score[m] = 0;
}

void solve(istream& cin, ostream& cout) {
  score[0] = 2;
  l n; cin >> n;
  vl v(n); F(i, 0, n) cin >> v[i];
  vl primes; vl next_div = sieve_primes(primes);
  unordered_map<l, set<l>> u;
  for (auto x : v) {
    auto ff = factorize_to_primes(x, primes, next_div);
    l prev = 0;
    l c = 0;
    for (auto f : ff) {
      if (f != prev and prev) {
        u[prev].emplace(c);
        c = 0;
      }
      c++;
      prev = f;
    }
    if (prev) u[prev].emplace(c);
  }
  // L(u);
  l oddity = 0, choices = 0;
  for (auto& kv : u) {
    l t = 0;
    for (auto i : kv.second) t += l(1) << i;
    l s = get_score(t);
    if (s > 0 and s < 2) oddity += s;
    if (s == 0) choices += 2;
    if (s == 3) choices++;
  }
  if (choices) {
    cout << ((choices % 2) ? "Mojtaba" : "Arpa") << lf;
  } else {
    cout << ((oddity % 2) ? "Mojtaba" : "Arpa") << lf;
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


#if defined(LOCAL)
#define PROBLEM_NAME "C"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

const l MAX_PRIME = 50000;
// returns v[i] = smallest prime divisor of i or 1
vl sieve_primes(vl& primes) {
  vl next_div(MAX_PRIME, 1);
  for (l i = 2; i < MAX_PRIME; i++) {
    if (next_div[i] != 1) continue;
    primes.emplace_back(i);
    for (l j = i; j < MAX_PRIME; j += i) if (next_div[j] == 1) next_div[j] = i;
  }
  return next_div;
}

// in asc order
vl factorize_to_primes(l n, vl& primes, vl& next_div) {
  auto p = primes.begin();
  vl result;
  while (n >= MAX_PRIME and p != primes.end()) {
    while (n % *p == 0) { result.emplace_back(*p); n /= *p; }
    p++;
  }
  if (n >= MAX_PRIME) {
    result.emplace_back(n);
    n = 1;
  }
  while (n != 1) {
    result.emplace_back(next_div[n]);
    n /= next_div[n];
  }
  return result;
}

void solve(istream& cin, ostream& cout) {
  l n; cin >> n;
  vl v(n); F(i, 0, n) cin >> v[i];
  vl primes; vl next_div = sieve_primes(primes);
  unordered_map<l, set<l>> u;
  for (auto x : v) {
    auto ff = factorize_to_primes(x, primes, next_div);
    l prev = 0;
    l c = 0;
    for (auto f : ff) {
      if (f != prev and prev) {
        u[prev].emplace(c);
        c = 0;
      }
      c++;
      prev = f;
    }
    if (prev) u[prev].emplace(c);
  }
  // L(u);
  l t = 0;
  for (auto& kv : u) t += kv.second.size();
  cout << ((t % 2) ? "Mojtaba" : "Arpa") << lf;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


#if defined(LOCAL)
#define PROBLEM_NAME "C"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

const l MAX_PRIME = 50000;
// returns v[i] = smallest prime divisor of i or 1
vl sieve_primes(vl& primes) {
  vl next_div(MAX_PRIME, 1);
  for (l i = 2; i < MAX_PRIME; i++) {
    if (next_div[i] != 1) continue;
    primes.emplace_back(i);
    for (l j = i; j < MAX_PRIME; j += i) if (next_div[j] == 1) next_div[j] = i;
  }
  return next_div;
}

// in asc order
vl factorize_to_primes(l n, vl& primes, vl& next_div) {
  auto p = primes.begin();
  vl result;
  while (n >= MAX_PRIME and p != primes.end()) {
    while (n % *p == 0) { result.emplace_back(*p); n /= *p; }
    p++;
  }
  if (n >= MAX_PRIME) {
    result.emplace_back(n);
    n = 1;
  }
  while (n != 1) {
    result.emplace_back(next_div[n]);
    n /= next_div[n];
  }
  return result;
}

mll score;

l get_score(l m) {
  if (score.count(m)) return score[m];
  bool one = false, two = false;
  l i = 1, j = 1;
  while (j <= m) {
    if (j & m) {
      l t = ((j - 1) & m) | (m >> i);
      l s = get_score(t);
      if (s == 0) {
        return score[m] = 3;
      }
      if (s == 1) two = true;
      if (s == 2) one = true;
    }
    i++; j = j << 1;
  }
  if (one and two) return score[m] = 3;
  if (one) return score[m] = 1;
  if (two) return score[m] = 2;
  return score[m] = 0;
}

void solve(istream& cin, ostream& cout) {
  score[0] = 2;
  l n; cin >> n;
  vl v(n); F(i, 0, n) cin >> v[i];
  vl primes; vl next_div = sieve_primes(primes);
  unordered_map<l, set<l>> u;
  for (auto x : v) {
    auto ff = factorize_to_primes(x, primes, next_div);
    l prev = 0;
    l c = 0;
    for (auto f : ff) {
      if (f != prev and prev) {
        u[prev].emplace(c);
        c = 0;
      }
      c++;
      prev = f;
    }
    if (prev) u[prev].emplace(c);
  }
  // L(u);
  l oddity = 0, choices = 0, bads = 0;
  for (auto& kv : u) {
    l t = 0;
    for (auto i : kv.second) t += l(1) << i;
    l s = get_score(t);
    if (s == 1) oddity++;
    // if (s == 0) oddity++;
    if (s == 3) choices++;
  }
  if (choices) {
    cout << ((choices % 2) ? "Mojtaba" : "Arpa") << lf;
  } else {
    cout << ((oddity % 2) ? "Mojtaba" : "Arpa") << lf;
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


#if defined(LOCAL)
#define PROBLEM_NAME "C"
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) debug(x)
#else
#define L(x, ...) (x)
#include <bits/stdc++.h>
#endif

using namespace std;
using vi = vector<int>; using vvi = vector<vi>;
using ii = pair<int,int>; using vii = vector<ii>;
using l = long long; using vl = vector<l>; using vvl = vector<vl>;
using ll = pair<l,l>; using vll = vector<ll>; using vvll = vector<vll>;
using lu = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using mll = unordered_map<l, l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10; static constexpr auto PI = acos(-1);
const l e0=1, e3=1000, e5=100000, e6=10*e5, e7=10*e6, e8=10*e7, e9=10*e8;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a,b,c) for (l a = l(b); a < l(c); a++)
#define B(a,b,c) for (l a = l(c) - 1; a >= l(b); a--)

const l MAX_PRIME = 50000;
// returns v[i] = smallest prime divisor of i or 1
vl sieve_primes(vl& primes) {
  vl next_div(MAX_PRIME, 1);
  for (l i = 2; i < MAX_PRIME; i++) {
    if (next_div[i] != 1) continue;
    primes.emplace_back(i);
    for (l j = i; j < MAX_PRIME; j += i) if (next_div[j] == 1) next_div[j] = i;
  }
  return next_div;
}

// in asc order
vl factorize_to_primes(l n, vl& primes, vl& next_div) {
  auto p = primes.begin();
  vl result;
  while (n >= MAX_PRIME and p != primes.end()) {
    while (n % *p == 0) { result.emplace_back(*p); n /= *p; }
    p++;
  }
  if (n >= MAX_PRIME) {
    result.emplace_back(n);
    n = 1;
  }
  while (n != 1) {
    result.emplace_back(next_div[n]);
    n /= next_div[n];
  }
  return result;
}

mll score;

l grindy(l m) {
  // L("grindy", m);
  if (score.count(m)) return score[m];
  unordered_set<l> s;
  l i = 1;
  while (true) {
    l j = l(1) << (i - 1);
    if (j > m) break;
    l t = ((j - 1) & m) | (m >> i);
    s.emplace(grindy(t));
    // if (t == 0) break;
    i++;
  }
  l j = 0;
  while (s.count(j)) j++;
  return score[m] = j;
}

void solve(istream& cin, ostream& cout) {
  score[0] = 0;
  l n; cin >> n;
  vl v(n); F(i, 0, n) cin >> v[i];
  vl primes; vl next_div = sieve_primes(primes);
  unordered_map<l, set<l>> u;
  for (auto x : v) {
    auto ff = factorize_to_primes(x, primes, next_div);
    l prev = 0;
    l c = 0;
    for (auto f : ff) {
      if (f != prev and prev) {
        u[prev].emplace(c);
        c = 0;
      }
      c++;
      prev = f;
    }
    if (prev) u[prev].emplace(c);
  }
  // L(u);
  l x = 0;
  for (auto& kv : u) {
    l t = 0;
    for (auto i : kv.second) t += l(1) << (i - 1);
    x ^= grindy(t);
  }
  if (x) {
    cout << "Mojtaba" << lf;
  } else {
    cout << "Arpa" << lf;
  }
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout << fixed << setprecision(15);
#if defined(LOCAL)
  // _generate_random_test = generate_random;
  // _solve_brute = solve_brute;
  // _player_b = player_b;
  // _custom_solution_checker = solution_checker;
  maybe_run_tests(cin, cout);
#else
  solve(cin, cout);
#endif
}


#include <bits/stdc++.h>

std::unordered_map<int, std::set<int> > cnt;

int n;

bool notprime[100005];
int prime[100005];

void pretreatment() {
	const int lim = 1e5;

	for (int i = 2; i <= lim; ++i) {
		if (!notprime[i]) prime[++*prime] = i;

		for (int j = 1; j <= *prime && i * prime[j] <= lim; ++i) {
			notprime[i * prime[j]] = 1;
			if (i % prime[j] == 0) break;
		}
	}
}

struct Hash {
	unsigned long long operator () (const std::set<int> &st) const {
		unsigned long long res = 0;
		for (int i: st)
			res = res * 37 + i;
		res = res * 41 + st.size();
		return res;
	}
};

std::unordered_map<std::set<int>, int, Hash> dp;

int SG(std::set<int> st) {
	if (st.empty()) return 0;
	if (dp.count(st)) return dp[st];

	std::set<int> sg;
	for (int i = *--st.end(); i; --i) {
		std::set<int> tmp;
		for (int j: st)
			tmp.insert(j >= i ? j - i : j);
		if (*tmp.begin() == 0) tmp.erase(tmp.begin());
		sg.insert(SG(tmp));
	}
	int res = 0;
	for (; sg.count(res); ++res);
	dp[st] = res;
	return res;
}

int main() {
	pretreatment();

	scanf("%d", &n);
	for (int x, i = 1; i <= n; ++i) {
		scanf("%d", &x);
		for (int j = 1; j <= *prime; ++j) {
			if (x % prime[j] == 0) {
				int tmp = 0;
				while (x % prime[j] == 0) {
					++tmp;
					x /= prime[j];
				}
				cnt[prime[j]].insert(tmp);
			}
		}
		if (x > 1) cnt[x].insert(1);
	}

	int sg = 0;

	for (auto it: cnt) {
		sg ^= SG(it.second);
	}

	puts(sg ? "Mojtaba" : "Arpa");

	return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int N;
int A[105];
map<int, int> P;
map<int, int> grundy;

int getGrundy(int x)
{
    if (grundy.count(x))
        return grundy[x];

    ll g = 0;
    for (int i = 0; i < 29; i++)
    {
        if (!(x >> i))
            break;
        int y = (x>>(i + 1))|(x&((1<<i) - 1));
        g |= 1LL<<getGrundy(y);
    }

    int ret = 0;
    while ((g & (1LL<<ret)))
        ret++;
    return grundy[x] = ret;
}

int main()
{
    ios::sync_with_stdio(0);

    cin >> N;
    for (int i = 0, a; i < N; i++)
    {
        cin >> a;
        for (int j = 2; (ll)j*j <= a; j++)
            if (a % j == 0)
            {
                int cnt = 0;
                while (a % j == 0)
                {
                    a /= j;
                    cnt++;
                }
                P[j] |= 1<<(cnt - 1);
            }
        if (a > 1)
            P[a] |= 1;
    }

    int ans = 0;
    for (map<int, int>::iterator it = P.begin(); it != P.end(); it++)
        ans ^= getGrundy(it->second);

    if (ans > 0)
        cout << "Mojtaba\n";
    else
        cout << "Arpa\n";

    return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int N;
int A[105];
map<int, int> P;
map<int, int> grundy;

int getGrundy(int x)
{
    if (grundy.count(x))
        return grundy[x];

    ll g = 0;
    for (int i = 0; i < 29; i++)
    {
        if (!(x & (1<<i)))
            continue;
        int y = (x>>(i + 1))|(x&((1<<i) - 1));
        g |= 1LL<<getGrundy(y);
    }

    int ret = 0;
    while ((g & (1LL<<ret)))
        ret++;
    return grundy[x] = ret;
}

int main()
{
    ios::sync_with_stdio(0);

    cin >> N;
    for (int i = 0, a; i < N; i++)
    {
        cin >> a;
        for (int j = 2; (ll)j*j <= a; j++)
            if (a % j == 0)
            {
                int cnt = 0;
                while (a % j == 0)
                {
                    a /= j;
                    cnt++;
                }
                P[j] |= 1<<(cnt - 1);
            }
        if (a > 1)
            P[a] |= 1;
    }

    int ans = 0;
    for (map<int, int>::iterator it = P.begin(); it != P.end(); it++)
        ans ^= getGrundy(it->second);

    if (ans > 0)
        cout << "Mojtaba\n";
    else
        cout << "Arpa\n";

    return 0;
}