#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int m, n;
  cin >> n >> m;
  vector<string> s(n);
  vector<pair<int, int>> t(n, {-1, -1});
  for (int i = 0; i < n; i++) cin >> s[i];
  bool ok = true;
  for (int i = 0; i < n; i++) {
    int k = 0;
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'X') {
        if (!j || s[i][j - 1] == '.') k++;
        if (t[i].first < 0) t[i].first = j;
        t[i].second = j;
      }
    }
    if (k > 1) ok = false;
  }
  int k = 0;
  pair<int, int> u({-1, -1});
  for (int i = 0; i < n; i++) {
    if (t[i].first < 0) continue;
    if (!i || t[i - 1].first < 0) k++;
    if (u.first < 0) u = t[i];
    if (u != t[i]) ok = false;
  }
  if (k > 1) ok = false;
  cout << (ok ? "YES" : "NO") << endl;
  return 0;
}
