#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const double eps = 1e-9;
const int inf = 1e9;
char a[1110][1110];
set<int> S;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    char c;
    int cnt = 0;
    for (int j = 0; j < m; j++) {
      cin >> c;
      if (c == 'X') ++cnt;
      a[i][j] = c;
    }
    if (cnt) S.insert(cnt);
  }
  if (S.size() > 1) return printf("NO"), 0;
  S.clear();
  for (int i = 0; i < m; i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      if (a[j][i] == 'X') ++cnt;
    }
    if (cnt) S.insert(cnt);
  }
  if (S.size() > 1)
    printf("NO");
  else
    printf("YES");
}
