#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, k, k1, a[5005], b, c, d, ans;
string s[5005];
int main() {
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    cin >> s[i];
    for (j = 0; j < m; j++) {
      if (s[i][j] == 'X' && k == 0) {
        k = 1;
        c = i, d = j;
      }
    }
  }
  for (i = c; i < n; i++) {
    k = 0;
    for (j = 0; j < m; j++) {
      if (s[i][j] == 'X') {
        k = 1;
        break;
      }
    }
    if (k == 0) {
      break;
    }
    for (j = d; j < m; j++) {
      if (s[i][j] == '.') {
        break;
      }
    }
    a[i] = j;
    if (i > c && a[i] != a[i - 1]) {
      printf("NO\n", c, i);
      return 0;
    }
    if (d > 0 && s[i][d - 1] == 'X') {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  return 0;
}
