Question
Magical Grid Check

In the land of puzzles, Veer was given a square grid of characters with side length N, where N is an odd number. Veer was tasked with determining if the grid was magical. A grid is considered magical if all the characters on both diagonals are the same, and all other characters not on the diagonals are identical but different from the diagonal character. Can you help Veer figure out whether the grid is magical or not?

Input
The first line of the input contains integer N.
Each of the next N lines contain N lowercase English latin characters.

Constraints
3 ≤ N ≤ 500
Note: N is odd.
Output
Print "YES" if the given grid is magical, else print "NO", without the quotes.
Example
Sample Input
5
xooox
oxoxo
ooxoo
oxoxo
xooox
Sample Output
YES
Explaination
All characters on its diagonal are the same.
All the characters other than the diagonal are same.
The characters on the diagonal and the rest of the grid do not match.
Thus, it is a magical grid.

Online