#include <bits/stdc++.h>
char a[600][600];
int main() {
  int hang, lie, haha = 0;
  scanf("%d %d", &hang, &lie);
  int i, j, h;
  for (i = 0; i < hang; i++) {
    scanf("%s", a[i]);
  }
  int s = -1, e = -1;
  int flag = 1;
  int shuchu = 1;
  for (i = 0; i < hang; i++) {
    for (j = 0; j < lie; j++) {
      if (a[i][j] == 'X') break;
    }
    if (j == lie) continue;
    for (j = 0; j < lie; j++) {
      if (flag == 1) {
        if (a[i][j] == 'X') {
          if (s == -1) s = j;
          if (e == lie - 1 || a[i][j + 1] != 'X') e = j;
          haha = 1;
        }
      } else {
        if (j < s) {
          if (a[i][j] == 'X') {
            shuchu = 0;
            break;
          }
        } else if (j >= s && j <= e) {
          if (a[i][j] != 'X') {
            shuchu = 0;
            break;
          }
        } else {
          if (a[i][j] == 'X') {
            shuchu = 0;
            break;
          }
        }
      }
    }
    if (shuchu == 0) break;
    if (haha == 1) flag = 0;
  }
  if (shuchu == 1) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
}
