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


public class Class2 {
	private static Class2 c = new Class2();
	private static InputClass in = c.new InputClass(System.in);
	private static OutputClass out = c.new OutputClass(System.out);
	private static int r = 0;
	private static int b = 0;
	private static int g = 0;
	public static void main(String[] args) throws Exception {
		int x = in.nextInt();
		in.nextLine();
		String[] flag = new String[x];
		for (int i = 0; i < x; i++) {
			flag[i] = in.next();
		}
		try {
			countColors(flag);
			boolean isHorizontal = whichPosition(flag);
			boolean changedColor[] = new boolean[2];
			char pivotColor = flag[0].charAt(0);
			int NoOflines[] = new int[3];
			int index = 0;
			if (isHorizontal) {
				for (int i = 0; i < flag.length; i++) {
					if (pivotColor == flag[i].charAt(0)) {
						NoOflines[index] += 1;
					} else if (pivotColor != flag[i].charAt(0) && !alreadyChanged(changedColor)) {
						pivotColor = flag[i].charAt(0);
						index++;
						NoOflines[index] += 1;
						if (changedColor[0]) {
							changedColor[1] = true;
						} else {
							changedColor[0] = true;
						}
					} else if (pivotColor != flag[i].charAt(0) && alreadyChanged(changedColor)) {

						throw null;
					}
					for (int j = 0; j < flag[0].length(); j++) {
						if (pivotColor != flag[i].charAt(j)) {
							throw null;
						}

					}
				}
				if (Equality(NoOflines)) {
					out.println("YES");
				} else {
					throw null;
				}
			} else {
				for (int i = 0; i < flag[0].length(); i++) {
					if (pivotColor == flag[0].charAt(i)) {
						NoOflines[index] += 1;
					} else if (pivotColor != flag[0].charAt(i) && !alreadyChanged(changedColor)) {
						pivotColor = flag[0].charAt(i);
						index++;
						NoOflines[index] += 1;
						if (changedColor[0]) {
							changedColor[1] = true;
						} else {
							changedColor[0] = true;
						}
					} else if (pivotColor != flag[0].charAt(i) && alreadyChanged(changedColor)) {

						throw null;
					}
					for (int j = 0; j < flag.length; j++) {
						if (pivotColor != flag[j].charAt(i)) {
							throw null;
						}

					}
				}
				if (Equality(NoOflines)) {
					out.println("YES");
				} else {
					throw null;
				}
			}
		} catch (Exception e) {
			out.println("NO");
		}
		out.close();
	}
	
	

public class InputClass {
	private InputStream stream;
	private int kiloByte = 1024;
	private byte[] buffer = new byte[kiloByte];
	private int currentBufferIndex;
	private int noOfChars;
	
	public InputClass (InputStream s)
	{
		stream = s;
	}
	
	public int readChar() throws Exception
	{
		if(noOfChars == -1)
		{
			throw new Exception("End Of File");
		}
		if(currentBufferIndex >= noOfChars)
		{
			currentBufferIndex = 0;
			try {
				noOfChars = stream.read(buffer);
			} catch (IOException e) {
				throw new Exception("Buffer is Empty");
			}
			if(noOfChars <= 0)
				return -1;
		}
		return buffer[currentBufferIndex++];
	}
	
	public char nextChar() throws Exception
	{
		char returnChar;
		int charValue = readChar();
		while(isSpaceChar(charValue))
		{
			charValue = readChar();
		}
		returnChar = (char)charValue;
		return returnChar;
	}
	
	public int nextInt() throws Exception
	{
		int charValueInUni = readChar();
		while(isSpaceChar(charValueInUni))
			charValueInUni = readChar();
		int sign = 1;
		if(charValueInUni == '-'){
			sign = -1;
			charValueInUni = readChar();
		}
		int intValue = 0;
		do
		{
			if(charValueInUni < '0' || charValueInUni > '9')
				throw new Exception("Your input doesn't consist of pure digits");
			intValue *= 10;
			intValue += charValueInUni - '0';
			charValueInUni = readChar();
		}while(!isSpaceChar(charValueInUni));
		
		return intValue * sign;
	}
	
	public Long nextLong() throws Exception
	{
		int charValueInUni = readChar();
		while(isSpaceChar(charValueInUni))
			charValueInUni = readChar();
		int sign = 1;
		if(charValueInUni == '-'){
			sign = -1;
			charValueInUni = readChar();
		}
		long longValue = 0;
		do
		{
			if(charValueInUni < '0' || charValueInUni > '9')
				throw new Exception("Your input doesn't consist of pure digits");
			longValue *= 10;
			longValue += charValueInUni - '0';
			charValueInUni = readChar();
		}while(!isSpaceChar(charValueInUni));
		
		return longValue * sign;
	}
	
	public float nextFloat() throws Exception
	{
		boolean point = false;
		float dividBy = 10.0f;
		float afterPoint;
		float radix = 10.0f;
		int charValueInUni = readChar();
		while(isSpaceChar(charValueInUni))
			charValueInUni = readChar();
		int sign = 1;
		if(charValueInUni == '-'){
			sign = -1;
			charValueInUni = readChar();
		}
		float floatValue = 0;
		do
		{	
			if(charValueInUni == '.')
			{
				if(!point)
				{
					point = true;
					charValueInUni = readChar();
				}
				else
				{
					throw new Exception("your number has more than radical point");
				}
			}
			else if(!point)
			{
				if(charValueInUni < '0' || charValueInUni > '9')
					throw new Exception("Your input doesn't consist of pure digits");
				floatValue *= radix;
				floatValue += charValueInUni - '0';
				charValueInUni = readChar();
			}
			else
			{
				if(charValueInUni < '0' || charValueInUni > '9')
					throw new Exception("Your input doesn't consist of pure digits");
				afterPoint = (charValueInUni - '0');
				afterPoint /= dividBy;
				
				dividBy *= radix;
				floatValue += afterPoint;
				charValueInUni = readChar();
			}
		}while(!isSpaceChar(charValueInUni));
		
		return floatValue * sign;
	}

	public double nextDouble() throws Exception
	{
		boolean point = false;
		double dividBy = 10.0d;
		double radix = 10.0d;
		
		double afterPoint;
		int charValueInUni = readChar();
		while(isSpaceChar(charValueInUni))
			charValueInUni = readChar();
		int sign = 1;
		if(charValueInUni == '-'){
			sign = -1;
			charValueInUni = readChar();
		}
		double doubleValue = 0;
		do
		{	
			if(charValueInUni == '.')
			{
				if(!point)
				{
					point = true;
					charValueInUni = readChar();
				}
				else
				{
					throw new Exception("your number has more than radical point");
				}
			}
			else if(!point)
			{
				if(charValueInUni < '0' || charValueInUni > '9')
					throw new Exception("Your input doesn't consist of pure digits");
				doubleValue *= radix;
				doubleValue += charValueInUni - '0';
				charValueInUni = readChar();
			}
			else
			{
				if(charValueInUni < '0' || charValueInUni > '9')
					throw new Exception("Your input doesn't consists of pure digits");
				afterPoint = (double)(charValueInUni - '0');
				afterPoint /= dividBy;
				
				dividBy *= radix;
				doubleValue += afterPoint;
				charValueInUni = readChar();
			}
		}while(!isSpaceChar(charValueInUni));
		
		return doubleValue * sign;
	}
	public float nextFloatAcc() throws Exception
	{
		String floatString = next();
		return Float.parseFloat(floatString);
	}

	public double nextDoubleAcc() throws Exception
	{
		String doubleString = next();
		return Double.parseDouble(doubleString);
	}
	
	public String next() throws Exception {
		int charValueInUni = readChar();
		while (isSpaceChar(charValueInUni))
			charValueInUni =  readChar();
		StringBuilder string = new StringBuilder();
		do {
			string.appendCodePoint(charValueInUni);
			charValueInUni = readChar();
		} while (!isSpaceChar(charValueInUni));
		return string.toString();
	}
	
	public String nextLine() throws Exception {
		int charValueInUni = readChar();
		StringBuilder string = new StringBuilder();
		 while (!isEndOfLine(charValueInUni)) {
			
			string.appendCodePoint(charValueInUni);
			charValueInUni = readChar();
		}
		
		return string.toString();
	}
	
	public boolean isSpaceChar(int charValueInUni)
	{
		return charValueInUni == ' ' || charValueInUni == '\r' || charValueInUni == '\t' || charValueInUni == '\n' 
				|| charValueInUni == -1;
	}
	
	public boolean isEndOfLine(int charValueInUni)
	{
		return charValueInUni == '\n' || charValueInUni == '\r';
	}


}

	
	
	public class OutputClass {
		private final PrintWriter writer;
		
		public OutputClass(OutputStream os)
		{
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(os)));
		}
		
		public OutputClass(Writer w)
		{
			writer = new PrintWriter(w);
			
		}
		
		public void print(Object...x) {
			for (int i = 0; i < x.length; i++) {
				if (i != 0)
					writer.print(' ');
				writer.print(x[i]);
			}
		}
		
		public void println(Object...x) {
			print(x);
			writer.println();
		}
		
		public void close() {
			writer.close();
		}

		public void flush() {
			writer.flush();
		}
	}
	private static boolean whichPosition(String[] x) {
		boolean flag = false;
		char pivotColor = x[0].charAt(0);
		for (int i = 0; i < x.length && !flag; i++) {
			if (x[i].charAt(0) != pivotColor) {
				flag = true;
			}
		}
		for (int i = 0; i < x[0].length() && flag; i++) {
			if (x[0].charAt(i) != pivotColor) {
				throw null;
			}
		}
		return flag;
	}

	private static boolean alreadyChanged(boolean x[]) {
		boolean y = true;
		for (int i = 0; i < x.length; i++) {
			y &= x[i];
		}
		return y;
	}

	private static boolean Equality(int x[]) {

		return (x[0] == x[1]) && (x[1] == x[2]) && (x[0] == x[2]);
	}
	private static void countColors(String []x)
    {
        for(int i = 0;i < x.length;i++)
        {
            for(int j = 0;j < x[i].length();j++)
            {
                if(x[i].charAt(j) == 'R')
                {
                    r++;
                }else if(x[i].charAt(j) == 'G')
                {
                    g++;
                }else if(x[i].charAt(j) == 'B')
                {
                    b++;
                }
            }
        }
        if(b != g || b != r)
            throw null;
    }
}
