#include <bits/stdc++.h>
using namespace std;
string board[505];
int mnx = 500, mny = 500;
int mxx = 0, mxy = 0;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    cin >> board[i];
    for (int j = 0; j < m; j++) {
      if (board[i][j] == 'X') {
        if (mnx >= i) {
          mnx = i;
        }
        if (mny >= j) {
          mny = j;
        }
        if (mxx <= i) {
          mxx = i;
        }
        if (mxy <= j) {
          mxy = j;
        }
      }
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (board[i][j] == 'X') {
        if (!(mnx <= i && i <= mxx && mny <= j && j <= mxy)) {
          printf("NO\n");
          return 0;
        }
      }
      if (board[i][j] == '.') {
        if (mnx <= i && i <= mxx && mny <= j && j <= mxy) {
          printf("NO\n");
          return 0;
        }
      }
    }
  printf("YES\n");
  return 0;
}
