#include <bits/stdc++.h>
using namespace ::std;
vector<string> v;
int n, m;
bool can() {
  int count = 0;
  int fx = -1, lx = -1;
  for (int j = 0; j < m; j++) {
    if (v[0][j] == 'X') {
      if (fx == -1) {
        fx = j;
      }
      lx = j;
    }
  }
  if (fx != -1) {
    int c = 0;
    for (int k = fx; k <= lx; k++) {
      c += (v[0][k] == 'X');
    }
    if (c != (lx - fx + 1)) return false;
    count += lx - fx + 1;
  }
  for (int i = 1; i < n; i++) {
    int c = 0;
    int afx = -1, alx = -1;
    for (int j = 0; j < m; j++) {
      if (v[i][j] == 'X') {
        if (afx == -1) {
          afx = j;
        }
        alx = j;
      }
    }
    if (afx != -1) {
      if (fx == -1) {
        fx = afx;
        lx = alx;
      } else {
        if (fx != afx || lx != alx) return false;
      }
      for (int k = fx; k <= lx; k++) {
        c += v[i][k] == 'X';
      }
      if (c != (lx - fx + 1)) return false;
      count += lx - fx + 1;
    }
  }
  if (count > 0)
    return true;
  else
    return false;
}
int main() {
  string carry;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> carry;
    v.push_back(carry);
  }
  bool ans = can();
  if (ans)
    puts("YES");
  else
    puts("NO");
  return 0;
}
