The flag of Berland is such rectangular field n × m that satisfies following conditions:

  * Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. 
  * Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color. 
  * Each color should be used in exactly one stripe. 



You are given a field n × m, consisting of characters 'R', 'G' and 'B'. Output "YES" (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print "NO" (without quotes).

Input

The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field.

Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.

Output

Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).

Examples

Input

6 5
RRRRR
RRRRR
BBBBB
BBBBB
GGGGG
GGGGG


Output

YES


Input

4 3
BRG
BRG
BRG
BRG


Output

YES


Input

6 7
RRRGGGG
RRRGGGG
RRRGGGG
RRRBBBB
RRRBBBB
RRRBBBB


Output

NO


Input

4 4
RRRR
RRRR
BBBB
GGGG


Output

NO

Note

The field in the third example doesn't have three parralel stripes.

Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.TreeSet;

public class Tester {
	public static long mod = (long) (1e9 + 7);

	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);

		int n = in.nextInt();
		int m = in.nextInt();
		char c[][] = new char[n][m];
		for (int i = 0; i < n; i++) {
			c[i] = in.nextLine().trim().toCharArray();
		}
		char r[][] = rotate(c);
		if (check(c) || check(r)) {
			out.println("YES");
		} else {
			out.println("NO");
		}
		out.close();
	}

	public static char[][] rotate(char c[][]) {
		int n = c.length;
		int m = c[0].length;
		char tmp[][] = new char[m][n];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				tmp[j][i] = c[i][j];
			}
		}
		return tmp;
	}

	public static boolean check(char c[][]) {
		int n = c.length;
		int m = c[0].length;
		if (n % 3 != 0)
			return false;
		HashSet<Character> h = new HashSet<>();
		TreeSet<Character> tmp = new TreeSet<>();
		tmp.clear();
		for (int i = 0; i < n / 3; i++) {
			for (int j = 0; j < m; j++) {
				tmp.add(c[i][j]);
			}
		}
		if (tmp.size() == 1) {
			h.add(tmp.first());
		} else {
			return false;
		}
		tmp.clear();
		for (int i = n / 3; i < 2 * (n / 3); i++) {
			for (int j = 0; j < m; j++) {
				tmp.add(c[i][j]);
			}
		}
		if (tmp.size() == 1) {
			h.add(tmp.first());
		} else {
			return false;
		}
		tmp.clear();
		for (int i = 2 * (n / 3); i < n; i++) {
			for (int j = 0; j < m; j++) {
				tmp.add(c[i][j]);
			}
		}
		if (tmp.size() == 1) {
			h.add(tmp.first());
		} else {
			return false;
		}
		return h.size() == 3;
	}

	public static void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	static long exp(long a, long b) {
		if (b == 0)
			return 1;
		if (b == 1)
			return a;
		if (b == 2)
			return a * a;

		if (b % 2 == 0)
			return exp(exp(a, b / 2), 2);
		else
			return a * exp(exp(a, (b - 1) / 2), 2);
	}

	static class Pair implements Comparable<Pair> {
		int x, y;

		Pair(int ii, int cc) {
			x = ii;
			y = cc;
		}

		public int compareTo(Pair o) {
			if (Long.compare(this.x, o.x) != 0)
				return Long.compare(this.x, o.x);
			else
				return Long.compare(this.y, o.y);
		}

		public int hashCode() {
			int hu = (int) (x ^ (x >>> 32));
			int hv = (int) (y ^ (y >>> 32));
			return 31 * hu + hv;
		}

		public boolean equals(Object o) {
			Pair other = (Pair) o;
			return x == other.x && y == other.y;
		}

		public String toString() {
			return "[x=" + x + ", y=" + y + "]";
		}

	}

	static final class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[1024];
		private int curChar;
		private int Chars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int read() throws IOException {
			if (curChar >= Chars) {
				curChar = 0;
				Chars = stream.read(buf);
				if (Chars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public final int nextInt() throws IOException {
			return (int) nextLong();
		}

		public final long nextLong() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
				if (c == -1)
					throw new IOException();
			}
			boolean negative = false;
			if (c == '-') {
				negative = true;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += (c - '0');
				c = read();
			} while (!isSpaceChar(c));
			return negative ? (-res) : (res);
		}

		public final int[] nextIntBrray(int size) throws IOException {
			int[] arr = new int[size];
			for (int i = 0; i < size; i++)
				arr[i] = nextInt();
			return arr;
		}

		public final String nextString() throws IOException {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.append((char) c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final String nextLine() throws IOException {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.append((char) c);
				c = read();
			} while (c != '\n' && c != -1);
			return res.toString();
		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}

}