import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np H, W = map(int, readline().split()) # 1次元の場合を実験して観察すると解ける S = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W] S = 1 * (S == b'o') x = S[::2, ::2].sum() + S[1::2, 1::2].sum() y = S.sum() - x print('NO' if (x - y) % 3 else 'YES')