#include <bits/stdc++.h>
using namespace std;
int compare(const void* x1, const void* x2) { return (*(int*)x1 - *(int*)x2); }
int main() {
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  char c;
  int a[n], b[m];
  for (int i = 0; i < m; i++) {
    b[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    a[i] = 0;
    for (int j = 0; j < m; j++) {
      cin >> c;
      if (c == 'X') {
        a[i]++;
        b[j]++;
      }
    }
  }
  bool f = true;
  int q = 0;
  for (int i = 0; i < n; i++) {
    if (a[i]) {
      if (q == 0) {
        q = a[i];
      } else {
        if (a[i] != q) {
          cout << "NO";
          return 0;
        }
      }
    }
  }
  q = 0;
  for (int i = 0; i < m; i++) {
    if (b[i]) {
      if (q == 0) {
        q = b[i];
      } else {
        if (b[i] != q) {
          cout << "NO";
          return 0;
        }
      }
    }
  }
  cout << "YES";
  return 0;
}
