#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
const long long LINF = 2e18;
void inv(bool e);
template <typename T>
void die(T& a);
bool brute, alter;
int cnt_tests = 1;
string s;
const int N = 505;
char mp[N][N];
int n, m;
void inp() {
  cin >> n >> m;
  string t;
  for (int i = 0; i < n; i++) {
    cin >> t;
    for (int j = 0; j < ((int)(t).size()); j++) {
      mp[i][j] = t[j];
    }
  }
}
int row[N], colmn[N];
void solve() {
  for (int i = 0; i < n; i++) {
    row[i] = 0;
    for (int j = 0; j < m; j++) {
      if (mp[i][j] == 'X') ++row[i];
    }
  }
  for (int i = 0; i < m; i++) {
    colmn[i] = 0;
    for (int j = 0; j < n; j++) {
      if (mp[j][i] == 'X') ++colmn[i];
    }
  }
  set<int> un_c, un_r;
  for (int i = 0; i < n; i++) {
    if (row[i] != 0) un_r.insert(row[i]);
  }
  for (int i = 0; i < m; i++) {
    if (colmn[i] != 0) un_c.insert(colmn[i]);
  }
  if (((int)(un_r).size()) == 1 && ((int)(un_c).size()) == 1) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
void stress() {}
void naive() {}
void run();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  if (0) {
    freopen("stack.in", "r", stdin);
    freopen("stack.out", "w", stdout);
  }
  brute = false;
  for (int i = 0; (i < cnt_tests); i++) {
    run();
  }
  cerr << '\n' << "Time: " << clock() / 1000.0 << " ms";
  return 0;
}
void run() {
  if (!brute) {
    inp();
  } else {
    stress();
  }
  solve();
}
template <typename T>
void die(T& a) {
  cout << a;
  exit(0);
}
void inv(bool e) {
  if (!e) {
    vector<int> a;
    a[-1] += 1;
  }
}
