function main(input){
  var line1 = parse(input[0]);
  var h = line1[0];
  var w = line1[1];
  var words = input.slice(1, h + 1);
  var twords = tenchi(words);

  console.log(findPair(words) && findPair(twords) ? 'YES' : 'NO');
}

function findPair(words) {
  var map = {};
  for (var i = 0; i < words.length; i++){
    var sortedWord = words[i].split('').sort().join('');
    if (map[sortedWord]) {
      delete map[sortedWord];
    } else {
      map[sortedWord] = true;
    }
  }

  return (Object.keys(map).length <= 1);
}

function tenchi(a) {
  var ret = [];
  for (var i = 0; i < a[0].length; i++) {
    ret.push('');
  }
  for (var i = 0; i < a.length; i++) {
    for (var j = 0; j < a[0].length; j++) {
      ret[j] += a[i][j];
    }
  }
  return ret;
}

function parse(line){
  var ret = [];
  var arr = line.split(' ');
  for (var i = 0; i < arr.length; i++) {
    ret.push(parseInt(arr[i]));
  }
  return ret;
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});
