#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  map<long long, long long> r, c;
  vector<string> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  long long count = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (v[i][j] == 'X') {
        r[i]++;
        c[j]++;
        count++;
      }
    }
  }
  set<long long> s;
  for (auto it = r.begin(); it != r.end(); it++) {
    s.insert(it->second);
  }
  if (s.size() > 1) {
    cout << "NO";
    return 0;
  }
  set<long long> k;
  for (auto it = c.begin(); it != c.end(); it++) {
    k.insert(it->second);
  }
  if (k.size() > 1) {
    cout << "NO";
    return 0;
  }
  if ((long long)(r.size() * c.size()) == count) {
    cout << "YES";
  } else
    cout << "NO";
  return 0;
}
