#include <bits/stdc++.h>
using namespace std;
const int N = 502;
int n, m, l = -1, ok = 1, r;
string s[N];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int j = 0; j < n; j++) {
    l = r = -1;
    for (int i = 0; i < s[j].length(); i++) {
      if (l == -1 && s[j][i] == 'X')
        l = r = i;
      else if (l != -1 && s[j][i] == 'X') {
        r = i;
      }
    }
    if (l != -1) break;
  }
  if (l == -1) {
    cout << "NO";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (int j = l; j <= r; j++)
      if (s[i][j] == 'X') cnt++;
    if (cnt != r - l + 1 && cnt != 0) ok = 0;
  }
  if (ok == 1)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < s[i].length(); j++)
        if ((j < l || j > r) && s[i][j] == 'X') ok = 0;
  if (ok)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
