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.PrintWriter;
import java.util.*;
 
public class B837 {
	public static void main(String[] args) {
		InputReader in = new InputReader();
		PrintWriter out = new PrintWriter(System.out);
		final long start = System.currentTimeMillis();		
		new Task1().solve(in, out);
		@SuppressWarnings("unused")
		final long duration = System.currentTimeMillis()-start;
		out.close();
	}

	static class Task1{	
		final static int MAX = 1000001;
		public void solve(InputReader in, PrintWriter out){
			int n = in.nextInt(), m = in.nextInt();
			
			String[] a = new String[n];
			for(int i=0; i<n; i++){
				String s = in.next();
				a[i] = s;
			}

			boolean flag = false;
			if(n%3==0){
				String temp1 = a[0];
				for(int i=1; i<temp1.length(); i++){
					if(temp1.charAt(i)!=temp1.charAt(i-1))
						flag = true;
				}
				for(int i=0; !flag && i<n/3; i++){
					if(!a[i].equals(temp1)){
						flag = true;
						break;
					}
				}

				String temp2 = a[n/3];
				for(int i=1; i<temp2.length(); i++){
					if(temp2.charAt(i)!=temp2.charAt(i-1))
						flag = true;
				}
				for(int i=n/3; !flag && i<2*n/3; i++){
					if(!a[i].equals(temp2)){
						flag = true;
						break;
					}
				}

				String temp3 = a[2*n/3];
				for(int i=1; i<temp3.length(); i++){
					if(temp3.charAt(i)!=temp3.charAt(i-1))
						flag = true;
				}
				for(int i=2*n/3; !flag && i<n; i++){
					if(!a[i].equals(temp3)){
						flag = true;
						break;
					}
				}

				if(!flag && !temp1.equals(temp2) && !temp2.equals(temp3) && !temp3.equals(temp1)){
					out.println("YES");
					return;
				}
			}

			flag = false;
			if(m%3==0){
				String[] b = new String[m];
				for(int i=0; i<m; i++){
					StringBuilder sb = new StringBuilder("");
					for(int j=0; j<n; j++){
						sb.append(a[j].charAt(i));
					}
					b[i] = sb.toString();
				}

				a = b;
				n = m;
				String temp1 = a[0];
				for(int i=1; i<temp1.length(); i++){
					if(temp1.charAt(i)!=temp1.charAt(i-1))
						flag = true;
				}
				for(int i=0; !flag && i<n/3; i++){
					if(!a[i].equals(temp1)){
						flag = true;
						break;
					}
				}

				String temp2 = a[n/3];
				for(int i=1; i<temp2.length(); i++){
					if(temp2.charAt(i)!=temp2.charAt(i-1))
						flag = true;
				}
				for(int i=n/3; !flag && i<2*n/3; i++){
					if(!a[i].equals(temp2)){
						flag = true;
						break;
					}
				}

				String temp3 = a[2*n/3];
				for(int i=1; i<temp3.length(); i++){
					if(temp3.charAt(i)!=temp3.charAt(i-1))
						flag = true;
				}
				for(int i=2*n/3; !flag && i<n; i++){
					if(!a[i].equals(temp3)){
						flag = true;
						break;
					}
				}

				if(!flag && !temp1.equals(temp2) && !temp2.equals(temp3) && !temp3.equals(temp1)){
					out.println("YES");
					return;
				}
			}

			out.println("NO");

		}

		long gcd(long a, long b){
			while(a!=0){
				long rem = b%a;
				b = a;
				a = rem;
			}
			return b;
		}

		long expo(long a, long b, long MOD){
			long result = 1;
			while (b>0){
				if (b%2==1) result=(result*a) ;
				b>>=1;
				a=(a*a) ;
			}
			return result ;
		}

		long inverseModullo(long numerator, long denominator, long MOD){
			return ((numerator )*(expo(denominator, MOD-2, MOD))) ;
		}
	}
	static class InputReader{
		final InputStream stream;
		final byte[] buf = new byte[8192];
		int curChar, numChars;
		SpaceCharFilter filter;
		public InputReader(){
			this.stream = System.in;
		}
		public int read(){
			if(numChars == -1) throw new InputMismatchException();
			if(curChar >= numChars){
				curChar = 0;
				try{
					numChars = stream.read(buf);
				} catch(IOException e){
					throw new InputMismatchException();
				}
				if(numChars <= 0) return -1;
			}
			return buf[curChar++];
		}
		public int nextInt(){
			int c = read();
			while(isSpaceChar(c)) c = read();
			int sgn = 1;
			if(c == '-'){
				sgn = -1;
				c = read();
			}
			int res = 0;
			do{
				if(c<'0' || c>'9') throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while(!isSpaceChar(c));
			return res*sgn;
		}
		public long nextLong(){
			int c = read();
			while(isSpaceChar(c)) c = read();
			int sgn = 1;
			if(c == '-'){
				sgn = -1;
				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 res*sgn;
		}
		public String next(){
			int c = read();
			while(isSpaceChar(c)) c = read();
			StringBuilder res = new StringBuilder();
			do{
				res.appendCodePoint(c);
				c = read();
			}while(!isSpaceChar(c));
			return res.toString();
		}
		public boolean isSpaceChar(int c){
			if(filter != null) return filter.isSpaceChar(c);
			return c==' ' || c=='\n' || c=='\r' || c=='\t' || c==-1;
		}
		public interface SpaceCharFilter{
			public boolean isSpaceChar(int ch);
		}
	}
}