#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n, flag = 0, check[1000], coun = 0;
  char str[1000][1000];
  cin >> m >> n;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      cin >> str[i][j];
      if (str[i][j] == 'X') coun++;
    }
    check[i] = coun;
    coun = 0;
  }
  for (int i = 0; i < m - 1; i++) {
    for (int j = 0; j < n; j++) {
      if (str[i][j] == 'X') {
        if (check[i] == check[i + 1]) {
          if (str[i][j] != str[i + 1][j]) {
            flag = 1;
            break;
          }
        } else if (check[i + 1] != 0) {
          flag = 1;
          break;
        }
      }
    }
    if (flag == 1) break;
  }
  if (flag == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
