Valera and X

题意翻译

Valera是一个小男孩。昨天,他的数学作业很多,因此他没有时间去温习英语课的单词表。不幸的是,英语老师决定在今天的课上进行一场单词小测。测试中,发下的试卷是正方形的,由许多小格子组成,共有n行n列(n是奇数),每个单位的小格子都包含一个英文字母。 Valera需要知道试卷上的小字母是否会组成一个大写字母“X”的形状。Valera的老师认为试卷上的字母会构成“X”,当且仅当: 1、所有对角线上的格子所包含的字母必须一致。 2、其他所有格子(不在对角线上的),也必须由相同的字母所组成且这个字母不能与对角线上的字母相同。 请你按照题面描述,编程帮Valera解决这个问题。 输入格式: 第1行包含一个整数n(3 <= n < 300,n是奇数) 第2~n+1行,每行包含n个英文字母,如题面描述。 输出格式 如果试卷上的字母能构成“X”,输出字符串“YES”;如果不能,则输出字符串“NO”。 输出不加双引号。

题目描述

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.

输入输出格式

输入格式


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

输出格式


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

输入输出样例

输入样例 #1

5
xooox
oxoxo
soxoo
oxoxo
xooox

输出样例 #1

NO

输入样例 #2

3
wsw
sws
wsw

输出样例 #2

YES

输入样例 #3

3
xpx
pxp
xpe

输出样例 #3

NO