#include <bits/stdc++.h>
long long int pow(long long int a, long long int b, long long int m) {
  long long int x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y);
      if (x > m) x %= m;
    }
    y = (y * y);
    if (y > m) y %= m;
    b /= 2;
  }
  return x % m;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long int gen(long long int start, long long int end) {
  long long int diff = end - start;
  long long int temp = rand() % start;
  return temp + diff;
}
using namespace std;
vector<string> v;
bool check(string s) {
  int i;
  bool a = 0, b = 0;
  for (i = 0; s[i] != '\0'; i++) {
    if (s[i] == 'X') a = 1;
    if (s[i] == '.') b = 1;
  }
  if (a == 1 && b == 1) return 0;
  return 1;
}
int main() {
  bool flag;
  int n, m, i, j;
  string s;
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (i = 1; i <= n; ++i) {
    cin >> s;
    v.push_back(s);
  }
  for (j = m - 1; j >= 0; --j) {
    flag = 1;
    for (i = 0; i <= n - 1; i++) {
      if (v[i][j] == 'X') {
        flag = 0;
        break;
      }
    }
    if (flag == 0)
      break;
    else {
      for (i = 0; i <= n - 1; i++) {
        v[i].erase(v[i].end() - 1);
      }
      --m;
    }
  }
  while (1) {
    flag = 1;
    for (i = 0; i <= n - 1; i++) {
      if (v[i][0] == 'X') {
        flag = 0;
        break;
      }
    }
    if (flag == 0)
      break;
    else {
      for (i = 0; i <= n - 1; i++) v[i].erase(v[i].begin());
    }
  }
  for (i = 0; i <= n - 1; i++) {
    v[i] = v[i] + v[i];
    if (check(v[i]) == 0) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
}
