human
Can you provide a Python program to find out whether their flag meets the new ISO standard given the following:
According to a new ISO standard, a flag of every country should have a chequered field n × m, each square should be of one of 10 colours, and the flag should be «striped»: each horizontal row of the flag should contain squares of the same colour, and the colours of adjacent horizontal rows should be different. Berland's government asked you to find out whether their flag meets the new ISO standard.

Input

The first line of the input contains numbers n and m (1 ≤ n, m ≤ 100), n — the amount of rows, m — the amount of columns on the flag of Berland. Then there follows the description of the flag: each of the following n lines contain m characters. Each character is a digit between 0 and 9, and stands for the colour of the corresponding square.

Output

Output YES, if the flag meets the new ISO standard, and NO otherwise.

Examples

Input

3 3
000
111
222

Output

YES

Input

3 3
000
000
111

Output

NO

Input

3 3
000
111
002

Output

NO
assistant
#Here is Python program to find out whether their flag meets the new ISO standard.

from math import *
from Queue import *

s = raw_input()
l = s.split(' ')
n = int(l[0])
m = int(l[1])
l = []
flag = True
for i in range(n):
    if not flag:
        break
    s = raw_input()
    for j in range(len(s)-1):
        if s[j] != s[j+1]:
            flag = False
            break
    l.append(s[0])
for i in range(len(l)-1):
    if l[i] == l[i+1]:
        flag = False
        break
if flag:
    print('YES')
else:
    print('NO')

    


"""class segment(object):
    def __init__(self, x1, y1, x2, y2):
        self.ver, self.hor, self.point = False, False, False
        if x1 == x2:
            self.ver = True
        if y1 == y2:
            self.hor = True
        if (x1 == x2) and (y1 == y2):
            self.point = True
        minx = min(x1,x2)
        maxx = max(x1,x2)
        miny = min(y1,y2)
        maxy = max(y1,y2)
        self.x1 = minx
        self.x2 = maxx
        self.y1 = miny
        self.y2 = maxy

def rectangle(horseg, verseg):
    if (horseg[0].x1 != horseg[1].x1) or (horseg[0].x2 != horseg[1].x2):
        return False
    if (verseg[0].y1 != verseg[1].y1) or (verseg[0].y2 != verseg[1].y2):
        return False
    miny = min(horseg[0].y1, horseg[1].y1)
    maxy = max(horseg[0].y1, horseg[1].y1)
    minx = min(verseg[0].x1, verseg[1].x1)
    maxx = max(verseg[0].x1, verseg[1].x1)
    if (minx != horseg[0].x1) or (maxx != horseg[0].x2):
        return False
    if (miny != verseg[0].y1) or (maxy != verseg[0].y2):
        return False
    return True

horseg = []
verseg = []
for i in xrange(4):
    s = raw_input()
    l = s.split(' ')
    new_seg = segment(int(l[0]), int(l[1]), int(l[2]), int(l[3]))
    if (new_seg.hor == False) and (new_seg.ver == False):
        print('NO')
        break
    if new_seg.point:
        print('NO')
        break
    if new_seg.hor:
        horseg.append(new_seg)
    else:
        verseg.append(new_seg)
if (len(horseg) != 2):
    print('NO')
else:
    if rectangle(horseg, verseg):
        print('YES')
    else:
        print('NO')"""

    
       ...