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
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.BufferedWriter;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 * 
 * @author Samin Arefin
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
	public void solve(int testNumber, InputReader in, OutputWriter out) {

		int n = in.nextInt();
		char[][] arr = new char[n][n];

		char match1;
		char match2;

		String lineFirst = in.nextLine();

		match1 = lineFirst.charAt(0);
		match2 = lineFirst.charAt(1);

		if (match1 == match2) {
			out.printLine("NO");
			return;
		}

		for (int i = 0; i < n; i++) {
			arr[0][i] = lineFirst.charAt(i);
			if (i == n - 1) {
				if (arr[0][i] != match1) {
					out.printLine("NO");
					return;
				}
			} else if (i != 0) {
				if (arr[0][i] != match2) {
					out.printLine("NO");
					return;
				}
			}
		}

		for (int i = 1; i < n; i++) {
			String lineOthers = in.nextLine();
			for (int j = 0; j < n; j++) {
				arr[i][j] = lineOthers.charAt(j);
				if (i == j) {
					if (arr[i][j] != match1) {
						out.printLine("NO");
						return;
					}
				} else if (n - 1 - i == j) {
					if (arr[i][j] != match1) {
						out.printLine("NO");
						return;
					}
				} else {
					if (arr[i][j] != match2) {
						out.printLine("NO");
						return;
					}
				}
			}
		}

		out.printLine("YES");
		//out.flush();
	}
}

class InputReader {

	private BufferedReader reader;
	private StringTokenizer token;

	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream));
	}

	public String next() {
		while (token == null || !token.hasMoreElements()) {
			try {
				token = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

		return token.nextToken();
	}

	public String nextLine() {
		String string = "";
		try {
			string = reader.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return string;
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public boolean isNotEmpty() {
		boolean flag = false;
		try {
			flag = reader.ready();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return flag;
	}

}

class OutputWriter {
	private final StringBuilder appender;
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
				outputStream)));
		appender = new StringBuilder();
	}

	public OutputWriter(Writer writer) {
		this.writer = new PrintWriter(writer);
		appender = new StringBuilder();
	}

	public void close() {
		writer.close();
	}

	public void printLine(Object o) {
		writer.println(o.toString());
	}

	public void write(Object o) {
		writer.write(o.toString());
	}

	public void print(Object o) {
		writer.print(o.toString());
	}

	public StringBuilder append(int n) {
		return appender.append(n);
	}

	public StringBuilder append(long l) {
		return appender.append(l);
	}

	public StringBuilder append(float f) {
		return appender.append(f);
	}

	public StringBuilder append(double d) {
		return appender.append(d);
	}

	public StringBuilder append(char c) {
		return appender.append(c);
	}

	public StringBuilder append(char[] charseq) {
		return appender.append(charseq);
	}

	public StringBuilder append(String string) {
		return appender.append(string);
	}

	public StringBuilder append(CharSequence charSequence) {
		return appender.append(charSequence);
	}

	public StringBuilder append(Object obj) {
		return appender.append(obj);
	}

	public StringBuilder append(boolean b) {
		return appender.append(b);
	}

	public StringBuilder append(StringBuffer stringBuffer) {
		return appender.append(stringBuffer);
	}

	public void flush() {
		print(appender);
	}

	public StringBuilder delete(int start, int end) {
		return appender.delete(start, end);
	}

	public int length() {
		return appender.length();
	}

}
