Valera is a little boy. Yesterday he got a huge Math hometask at school, so Valera didn't have enough time to properly learn the English alphabet for his English lesson. Unfortunately, the English teacher decided to have a test on alphabet today. At the test Valera got a square piece of squared paper. The length of the side equals n squares (n is an odd number) and each unit square contains some small letter of the English alphabet.

Valera needs to know if the letters written on the square piece of paper form letter "X". Valera's teacher thinks that the letters on the piece of paper form an "X", if:  on both diagonals of the square paper all letters are the same;  all other squares of the paper (they are not on the diagonals) contain the same letter that is different from the letters on the diagonals. 

Help Valera, write the program that completes the described task for him.


-----Input-----

The first line contains integer n (3 ≤ n < 300; n is odd). Each of the next n lines contains n small English letters — the description of Valera's paper.


-----Output-----

Print string "YES", if the letters on the paper form letter "X". Otherwise, print string "NO". Print the strings without quotes.


-----Examples-----
Input
5
xooox
oxoxo
soxoo
oxoxo
xooox

Output
NO

Input
3
wsw
sws
wsw

Output
YES

Input
3
xpx
pxp
xpe

Output
NO

Difficulty: interview

Starter code:

Solutions:
n=int(input())

L=[]
for i in range(n):
    L.append(input())
valid=True
x=0
y=0
E=[]
p=L[0][0]
while(x<n and y<n):
    if(L[x][y]!=p):
        valid=False
    x+=1
    y+=1
    
x=0
y=n-1

while(x<n and y>=0):
    if(L[x][y]!=p):
        valid=False
    x+=1
    y-=1
K={}
for i in range(n):
    for j in range(n):
        if(L[i][j] in K):
            K[L[i][j]]+=1
        else:
            K[L[i][j]]=1


if(not valid or K[p]!=2*n-1 or len(K)!=2):
    print("NO")

else:
    print("YES")


#!/usr/bin/env python3

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

n, = read_ints()

t = [ input() for _ in range(n) ]

def check():
	if t[0][0] == t[0][1]:
		return False
	
	for x in range(n):
		if t[x][x]!=t[0][0]:
			return False
		if t[x][n-x-1]!=t[0][0]:
			return False

		for y in range(n):
			if x==y or x==n-y-1:
				continue
			if t[x][y] != t[0][1]:
				return False
	return True

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






n = int(input())
s = input()
ans = 'YES'
s1 = s[0]
s2 = s[1]
if s[n - 1] != s1 or s1 == s2:
    ans = 'NO'
for i in range(1, n - 1):
    if s[i] != s2:
        ans = 'NO'
for i in range(1, n):
    s = input()
    p1 = i
    p2 = n - 1 - i
    if s[p1] != s1 or s[p2] != s1:
        ans = 'NO'
    for j in range(n):
        if j != p1 and j != p2 and s[j] != s2:
            ans = 'NO'
print(ans)


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().strip())
a = []
for i in range(n):
    a.append(input().strip())
ch = a[0][0]
fl = True
for i in range(n):
    if a[i][i] != ch or a[i][n - i - 1] != ch:
        fl = False
        break
ch2 = a[0][1]
if ch == ch2:
    fl = False
for i in range(n):
    for j in range(n):
        if i != j and j != n - i - 1:
            if a[i][j] != ch2:
                fl = False
                break
            
if fl:
    print('YES')
else:
    print('NO')

__author__ = 'Adela'


def main():
    n = int(input())
    diag = 'A'
    other = 'A'
    for i in range(n):
        for j, ch in enumerate(input()):
            if diag == 'A':
                diag = ch
            elif other == 'A':
                other = ch
            else:
                if i == j or i == (n-1-j):
                    if ch != diag:
                        print("NO")
                        return
                else:
                    if ch != other:
                        print("NO")
                        return
    if diag == other:
        print("NO")
    else:
        print("YES")


def __starting_point():
    main()

__starting_point()

n = int(input())

grid = []
for i in range(n):
    grid.append(input())

x = grid[0][0]
o = grid[0][1]
if x==o:
    print("NO")
else:
    fine = True
    for i in range(n):
        if fine:
            for j in range(n):
                if j==i or j==n-1-i:
                    if grid[i][j]!=x:
                        print("NO")
                        fine = False
                        break
                elif grid[i][j]!=o:
                    print("NO")
                    fine = False
                    break
    if fine: print("YES")


'''
Created on 19.03.2014

@author: mboeschen
'''
import sys

#inp = open("input.txt")
inp=sys.stdin

x=inp.readline()
n = int(x)
ls=[]
for i in range(n):
    ls.append(inp.readline())

a=ls[0][0]
b=ls[0][1]
Answer=True

if(a==b): 
    Answer=False    
    
for i in range(n):
    for j in range(n):
        if(i==j or n-i-1==j): 
            if(ls[i][j]!=a): 
                Answer=False
        else:
            if(ls[i][j]!=b): Answer=False
            
if(Answer):
    print("YES")
else:
    print("NO")
                
        




n=int(input())
b=[input() for i in range(n)]
l=b[0][0]
c=b[0][1]
flag=True
for i in range(n):
    if(i==((n//2))):
        if((b[i][i]!=l)or(b[i].count(l)!=1)or(b[i].count(c)!=n-1)):
            flag=False
            break
    else:
        if((b[i][i]!=l) or (b[i][n-1-i]!=l) or (b[i].count(l)!=2)or(b[i].count(c)!=n-2)):
            flag=False
            break
if flag:
    print("YES")
else:
    print("NO")

n = int(input())
A = [input() for _ in range(n)]
x = A[0][0]
a = A[0][1]
if x != a:
    msg = "YES"
    for i in range(n):
        for j in range(n):
            if i == j or i == n - j - 1:
                if A[i][j] != x:
                    msg = "NO"
                    break
            else:
                if A[i][j] != a:
                    msg = "NO"
                    break
else:
    msg = "NO"
print(msg)


n = int(input())
field = [input().strip() for x in range(n)]
for i in range(n):
    for j in range(n):
        if (j == i and field[i][j] != field[0][0]) or (j == n - 1 - i and field[i][j] != field[0][0]) or (n > 2) * (j not in [i, n - i - 1] and (field[i][j] != field[0][1] or field[i][j] == field[0][0])):
            print('NO')
            return
print('YES')


lines = int(input())
grid = []
result = "YES"

for i in range(lines):
    grid.append(input())

x_char = grid[0][0]
    
test = ("".join([i for i in grid]))
    
if len("".join(set(test))) > 2:
    result = "NO"
else:
    for i in range(lines // 2 + 1):
        if grid[i] != grid[-(i + 1)]:
            result = "NO"
            break
        if grid[i][i] != grid[i][-(i + 1)]:
            result = "NO"
            break
        if grid[i][i] != x_char:
            result = "NO"
            break
        if grid[i].count(x_char) > 2:
            result = "NO"
            break
if grid[lines // 2].count(x_char) > 1:
    result = "NO"
        
print(result)    

n = int(input())
d = 1
k = 0
for i in range(n):
    s = input()
    if d == 1:
        if k == 0:
            k = 1
            if s[1]*(n-2) == s[1:(n-1)] and s[0] == s[n-1]:
                c = s[1]
                b = s[0]
            else:
                d = 0
        elif c == b:
            d = 0
        else:
            j = i
            if i > n//2:
                j = n-i-1
            if i == n//2:
                if s != c*j + b + c*(n-j-1):
                    d = 0
            elif s != c*j + b + c*(n-2*j-2) + b + c*j:
                d = 0
                #print(i,j,s, c*j + b + c*(n-2*j-2) + b + c*j)
if d == 1:
    print('YES')
else:
    print('NO')

def test(sq, n):
  a, b = sq[0][0], sq[0][1]
  if a == b:
    return False
  else:
    for i in range(n):
      if sq[i][i] != a or sq[i][-i-1] != a:
        return False
    return sum([l.count(b) for l in sq]) == n*n - 2*n + 1

n = int(input())
sq = []
for i in range(n):
  sq.append(input())

print("YES" if test(sq,n) else "NO")

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys


n = int(input())

lines = [input() for _ in range(n)]

if len(set(c for l in lines for c in l)) != 2:
    print('NO')
    return

for i in range(n):
    if lines[0][0] != lines[i][i] or lines[0][0] != lines[i][-i-1]:
        print('NO')
        return
    if lines[i].count(lines[0][0]) != (1 if i == n // 2 else 2):
        print('NO')
        return
print('YES')


g=input
n=int(g())
p=[g()for _ in range(n)]
x=p[0][0]
if len(set(c for l in p for c in l))!=2:print('NO');return
print('YNEOS'[any(1 for i in range(n)if x!=p[i][i]or x!=p[i][-i-1]or p[i].count(x)!=(1 if i==n//2 else 2))::2])

n = int(input())
flag = True
line = input()
if line[0] == line[-1]:
    bgn = line[0]
else:
    flag = False
avr = line[1]

for i in range(n - 3):
    if not (line[i + 2] == avr):
        flag = False
        break
if not flag or avr == bgn:
    print ("NO")
    return
    
else:
    for j in range(n - 1):
        line = input()
        k = j + 1
        for t in range(n):
            if (t == k or t == n - k - 1) and not(line[t] == bgn):
                flag = False
                break
            if not (t == k or t == n - k - 1) and not (line[t] == avr):
                flag = False
                break

if flag:
    print ("YES")
else:
    print ("NO")



    


n = int(input())
res = 'YES'
s = list(input())
chk = s[0]
nul = s[1]
if s[0] != chk or s[n-1] != chk or s[0] == nul or s[n-1] == nul:
    res = 'NO'
s[0] = nul
s[n-1] = nul
if not all([x == nul for x in s]):
    res = 'NO'
if res == 'YES':
    for j in range(1, n):
        s = list(input())
        if s[j] != chk or s[n-1-j] != chk or s[j] == nul or s[n-1-j] == nul:
            res = 'NO'
        s[j] = nul
        s[n-1-j] = nul
        if not all([x == nul for x in s]):
            res = 'NO'
print(res)


n = int(input())
a=[]
f=False
for i in range(n):
    a.append(input())
    if a[i][i]!=a[i][n-1-i]:
        f=True
        break
c=a[0][1]
k=n//2
if not(f):
    if c==a[0][0] or (a[k][k]!=a[0][0]):
        f=True
    else:
        for i in range(n):
            for j in range(n):
                if i!=j and j!=n-1-i:
                    if a[i][j]!=c:
                        f=True
                        break
            if f: break
if f:
    print('NO')
else:
    print('YES')

n=int(input())
a=[]
flag=1
for i in range(0,n):
    a.append(input())
    for j in range(0,n):
        if i+j==n-1 or i-j==0:
            flag&=(a[-1][j]==a[0][0])
        else:
            flag&=(a[-1][j]==a[0][1]) & (a[-1][j]!=a[0][0])
if flag:
    print("YES")
else:
    print("NO")


col = int(input())
for i in range(col):
    line = input()
    if i == 0:
        a = line[0]
        b = line[1]
        if a == b:
            print("NO")
            break
    st = 0
    ed = col - 1
    while st <= ed:
        if st == i or ed == i:
            ch = a
        else:
            ch = b
        if line[st] != ch or line[ed] != ch:
            break;
        st += 1
        ed -= 1
    if st <= ed:
        print("NO")
        break
else:
    print('YES')
    


n = int(input())
x_smb = set()
o_smb = set()
flag_yes = True
for i in range(n):
    next_str = list(str(input()))
    x_smb = x_smb | set([next_str[i], next_str[-i-1]])
    for j in sorted(list(set((i, n-i-1))), reverse=True):
        next_str.pop(j)
    o_smb = o_smb | set(next_str)
    if len(x_smb) != 1 or len(o_smb) != 1 or len(x_smb | o_smb) == 1:
        print('NO')
        flag_yes = False
        break
if flag_yes:
    print('YES')


n = int(input())
s = input()
diag = s[0]
notdiag = s[1]

result = 'YES'
if s[-1] != diag:
    result = 'NO'
if s[1:-1] != notdiag * len(s[1:-1]):
    result = 'NO'
if diag == notdiag:
    result = 'NO'
#print(result)

if result == 'YES':
    for i in range(1, n):

        s = input()
        if s[i] != diag or s[-i-1] != diag:
            result = 'NO'
            break

        if i*2+1 == n:
            line = s[:i] + s[i+1:]
        else:
            i = min(i, n-i-1)
            if i:
                line = s[:i] + s[i+1:-i-1] + s[-i:]
            else:
                line = s[:i] + s[i+1:-i-1]

        if line != notdiag * len(line):
            result = 'NO'

        #print(i, line)




print(result)





def solve(arr, n):
    symbol = arr[0][0]
    for i in range(0,n):
        if arr[i][i] != symbol:
            return 'NO'
    j=0
    for i in range(n-1,-1,-1):
        if arr[i][j] != symbol:
            return 'NO'
        j+=1
    return 'YES'


n = int(input())

chars = []
while len(chars) < n:    
    s = input()
    chars.append(list(s))

L = sum(chars,[])
amount = set(sum(chars,[]))

if len(amount) == 2 and L.count(L[0]) == n*2-1:
    print(solve(chars, n))
else:
    print('NO')

def f():
    n = int(input())
    k, m = n // 2, n - 2
    t = input()
    a, b = t[0], t[1]
    if a == b: return 'NO'
    if t != a + b * m + a: return 'NO'
    for i in range(1, k):
        if input() != b * i + a + b * (m - 2 * i) + a + b * i: return 'NO'
    if input() != b * k + a + b * k: return 'NO'
    for i in range(k - 1, -1, -1):
        if input() != b * i + a + b * (m - 2 * i) + a + b * i: return 'NO'
    return 'YES'
print(f())