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.util.ArrayList;
import java.util.InputMismatchException;
import java.util.Locale;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

 
 
public class Main {
    
	public static int[][] R = {{-1, -1}, {-1, -1}};
	public static int[][] G = {{-1, -1}, {-1, -1}};
	public static int[][] B = {{-1, -1}, {-1, -1}};
	
	
	public static void main(String[] args) throws Exception {

        solve(1);
    	
    }
 
    
    public static void solve(int testCases) throws Exception{
    	
    	int n = StdIn.readInt();
    	int m = StdIn.readInt();
    	char[][] flag = new char[n][m];
    	for(int i = 0 ; i < n ; i++){
    		flag[i] = StdIn.readString().toCharArray();
    	}
    		
    	
    	for(int i = 0 ; i < n ; i++){
    		for(int j = 0 ; j < m ; j++){
    			setValue(flag[i][j], i, j);
    		}
    	}
    	/*
    	StdOut.println(R[0][0] + " " + R[0][1]);
    	StdOut.println(R[1][0] + " " + R[1][1]);
    	
    	StdOut.println(G[0][0] + " " + G[0][1]);
    	StdOut.println(G[1][0] + " " + G[1][1]);
    	
    	StdOut.println(B[0][0] + " " + B[0][1]);
    	StdOut.println(B[1][0] + " " + B[1][1]);
    	*/
    	for(int i = 0 ; i < 2 ; i++){
    		for(int j = 0 ; j < 2 ; j++){
    			if(R[i][j] == -1 || G[i][j] == -1 || B[i][j] == -1){
    				StdOut.println("NO");
    				return;
    			}
    		}
    	}
    	
    	for(int i = R[0][0] ; i <= R[0][1] ; i++){
    		for(int j = R[1][0] ; j <= R[1][1]; j++){
    			if(flag[i][j] != 'R'){
    				StdOut.println("NO");
    				return;
    			}
    		}
    	}
    	
    	for(int i = G[0][0] ; i <= G[0][1] ; i++){
    		for(int j = G[1][0] ; j <= G[1][1]; j++){
    			if(flag[i][j] != 'G'){
    				StdOut.println("NO");
    				return;
    			}
    		}
    	}
    	
    	for(int i = B[0][0] ; i <= B[0][1] ; i++){
    		for(int j = B[1][0] ; j <= B[1][1]; j++){
    			if(flag[i][j] != 'B'){
    				StdOut.println("NO");
    				return;
    			}
    		}
    	}
    	
    	if((R[0][1] - R[0][0] == G[0][1] - G[0][0]) && (R[0][1] - R[0][0] == B[0][1] - B[0][0]) && (R[1][1] - R[1][0] == G[1][1] - G[1][0]) && (R[1][1] - R[1][0] == B[1][1] - B[1][0]))
    		StdOut.println("YES");
    	else
    		StdOut.println("NO");
    }
    
    public static void setValue(char c, int row, int col){
    	//StdOut.println(c + " " + row + " " + col);
    	if(c == 'R'){
    		if(R[0][0] == -1 || row < R[0][0]){
    			R[0][0] = row;
    		}
    		if(row > R[0][1]){
    			R[0][1] = row;
    		}
    		if(R[1][0] == -1 || col < R[1][0]){
    			R[1][0] = col;
    		}
    		if(col > R[1][1]){
    			R[1][1] = col;
    		}
    	}else if(c == 'G'){
    		if(G[0][0] == -1 || row < G[0][0]){
    			G[0][0] = row;
    		}
    		if(row > G[0][1]){
    			G[0][1] = row;
    		}
    		if(G[1][0] == -1 || col < G[1][0]){
    			G[1][0] = col;
    		}
    		if(col > G[1][1]){
    			G[1][1] = col;
    		}
    	}else if(c == 'B'){
    		if(B[0][0] == -1 || row < B[0][0]){
    			B[0][0] = row;
    		}
    		if(row > B[0][1]){
    			B[0][1] = row;
    		}
    		if(B[1][0] == -1 || col < B[1][0]){
    			B[1][0] = col;
    		}
    		if(col > B[1][1]){
    			B[1][1] = col;
    		}
    	}
    }
         
}



final class StdIn {
 
    private StdIn() { }
 
    private static Scanner scanner;
    
    private static final String CHARSET_NAME = "UTF-8";
 
    private static final Locale LOCALE = Locale.US;
 
    private static final Pattern WHITESPACE_PATTERN = Pattern.compile("\\p{javaWhitespace}+");
 
    private static final Pattern EMPTY_PATTERN = Pattern.compile("");
 
    private static final Pattern EVERYTHING_PATTERN = Pattern.compile("\\A");
 
    public static boolean isEmpty() {
        return !scanner.hasNext();
    }
 
    public static boolean hasNextLine() {
        return scanner.hasNextLine();
    }
 
    public static boolean hasNextChar() {
        scanner.useDelimiter(EMPTY_PATTERN);
        boolean result = scanner.hasNext();
        scanner.useDelimiter(WHITESPACE_PATTERN);
        return result;
    }
 
    public static String readLine() {
        String line;
        try                 { line = scanner.nextLine(); }
        catch (Exception e) { line = null;               }
        return line;
    }
 
    public static char readChar() {
        scanner.useDelimiter(EMPTY_PATTERN);
        String ch = scanner.next();
        assert (ch.length() == 1) : "Internal (Std)In.readChar() error!"
            + " Please contact the authors.";
        scanner.useDelimiter(WHITESPACE_PATTERN);
        return ch.charAt(0);
    }  
 
 
    public static String readAll() {
        if (!scanner.hasNextLine())
            return "";
 
        String result = scanner.useDelimiter(EVERYTHING_PATTERN).next();
        // not that important to reset delimeter, since now scanner is empty
        scanner.useDelimiter(WHITESPACE_PATTERN); // but let's do it anyway
        return result;
    }
 
    public static String readString() {
        return scanner.next();
    }
 
    public static int readInt() {
        return scanner.nextInt();
    }
 
    public static double readDouble() {
        return scanner.nextDouble();
    }
 
    public static float readFloat() {
        return scanner.nextFloat();
    }
 
    public static long readLong() {
        return scanner.nextLong();
    }
    
    public static short readShort() {
        return scanner.nextShort();
    }
 
    public static byte readByte() {
        return scanner.nextByte();
    }
 
    public static boolean readBoolean() {
        String s = readString();
        if (s.equalsIgnoreCase("true"))  return true;
        if (s.equalsIgnoreCase("false")) return false;
        if (s.equals("1"))               return true;
        if (s.equals("0"))               return false;
        throw new InputMismatchException();
    }
 
    public static String[] readAllStrings() {
        // we could use readAll.trim().split(), but that's not consistent
        // because trim() uses characters 0x00..0x20 as whitespace
        String[] tokens = WHITESPACE_PATTERN.split(readAll());
        if (tokens.length == 0 || tokens[0].length() > 0)
            return tokens;
 
        // don't include first token if it is leading whitespace
        String[] decapitokens = new String[tokens.length-1];
        for (int i = 0; i < tokens.length - 1; i++)
            decapitokens[i] = tokens[i+1];
        return decapitokens;
    }
 
    public static String[] readAllLines() {
        ArrayList<String> lines = new ArrayList<String>();
        while (hasNextLine()) {
            lines.add(readLine());
        }
        return lines.toArray(new String[0]);
    }
 
    public static int[] readAllInts() {
        String[] fields = readAllStrings();
        int[] vals = new int[fields.length];
        for (int i = 0; i < fields.length; i++)
            vals[i] = Integer.parseInt(fields[i]);
        return vals;
    }
 
    public static double[] readAllDoubles() {
        String[] fields = readAllStrings();
        double[] vals = new double[fields.length];
        for (int i = 0; i < fields.length; i++)
            vals[i] = Double.parseDouble(fields[i]);
        return vals;
    }
    
    static {
        resync();
    }
 
    private static void resync() {
        setScanner(new Scanner(new java.io.BufferedInputStream(System.in), CHARSET_NAME));
    }
    
    private static void setScanner(Scanner scanner) {
        StdIn.scanner = scanner;
        StdIn.scanner.useLocale(LOCALE);
    }
 
    public static int[] readInts() {
        return readAllInts();
    }
 
    public static double[] readDoubles() {
        return readAllDoubles();
    }
 
    public static String[] readStrings() {
        return readAllStrings();
    }
 
}
 
final class StdOut {
 
    private static final String CHARSET_NAME = "UTF-8";
 
    private static final Locale LOCALE = Locale.US;
 
    private static PrintWriter out;
 
    static {
        try {
            out = new PrintWriter(new OutputStreamWriter(System.out, CHARSET_NAME), true);
        }
        catch (UnsupportedEncodingException e) { System.out.println(e); }
    }
 
    private StdOut() { }
 
    public static void close() {
        out.close();
    }
 
    public static void println() {
        out.println();
    }
 
    public static void println(Object x) {
        out.println(x);
    }
 
    public static void println(boolean x) {
        out.println(x);
    }
 
    public static void println(char x) {
        out.println(x);
    }
 
    public static void println(double x) {
        out.println(x);
    }
 
    public static void println(float x) {
        out.println(x);
    }
 
    public static void println(int x) {
        out.println(x);
    }
 
    public static void println(long x) {
        out.println(x);
    }
 
    public static void println(short x) {
        out.println(x);
    }
 
    public static void println(byte x) {
        out.println(x);
    }
 
    public static void print() {
        out.flush();
    }
 
    public static void print(Object x) {
        out.print(x);
        out.flush();
    }
 
    public static void print(boolean x) {
        out.print(x);
        out.flush();
    }
 
    public static void print(char x) {
        out.print(x);
        out.flush();
    }
 
    public static void print(double x) {
        out.print(x);
        out.flush();
    }
 
    public static void print(float x) {
        out.print(x);
        out.flush();
    }
 
    public static void print(int x) {
        out.print(x);
        out.flush();
    }
 
    public static void print(long x) {
        out.print(x);
        out.flush();
    }
 
    public static void print(short x) {
        out.print(x);
        out.flush();
    }
 
    public static void print(byte x) {
        out.print(x);
        out.flush();
    }
 
    public static void printf(String format, Object... args) {
        out.printf(LOCALE, format, args);
        out.flush();
    }
 
    public static void printf(Locale locale, String format, Object... args) {
        out.printf(locale, format, args);
        out.flush();
    }
 
} 