There is an H \times W grid (H vertical, W horizontal), where each square contains a lowercase English letter. Specifically, the letter in the square at the i-th row and j-th column is equal to the j-th character in the string S_i.

Snuke can apply the following operation to this grid any number of times:

* Choose two different rows and swap them. Or, choose two different columns and swap them.



Snuke wants this grid to be symmetric. That is, for any 1 \leq i \leq H and 1 \leq j \leq W, the letter in the square at the i-th row and j-th column and the letter in the square at the (H + 1 - i)-th row and (W + 1 - j)-th column should be equal.

Determine if Snuke can achieve this objective.

Constraints

* 1 \leq H \leq 12
* 1 \leq W \leq 12
* |S_i| = W
* S_i consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:


H W
S_1
S_2
:
S_H


Output

If Snuke can make the grid symmetric, print `YES`; if he cannot, print `NO`.

Examples

Input

2 3
arc
rac


Output

YES


Input

3 7
atcoder
regular
contest


Output

NO


Input

12 12
bimonigaloaf
faurwlkbleht
dexwimqxzxbb
lxdgyoifcxid
ydxiliocfdgx
nfoabgilamoi
ibxbdqmzxxwe
pqirylfrcrnf
wtehfkllbura
yfrnpflcrirq
wvcclwgiubrk
lkbrwgwuiccv


Output

YES
import java.util.*;
import java.io.*;

class Main{
    public static void main(String[] args){
	new Main().run();
    }
    
    void run(){
	Scanner sc=new Scanner();
	int H=sc.nextInt();
	int W=sc.nextInt();
	char[][] map=new char[H][W];
	for(int i=0;i<H;++i){
	    map[i]=sc.next().toCharArray();
	}
	int[] bind=new int[W];
	Arrays.fill(bind,-1);
	System.out.println(func(map,bind,0,W,W%2==1)?"YES":"NO");
    }

    boolean func(char[][] map,int[] bind,int pos,int res,boolean odd){
	if(res==0){
	    return calc(map,bind);
	}
	while(pos<bind.length&&bind[pos]!=-1)
	    ++pos;
	boolean ret=false;
	if(odd){
	    bind[pos]=pos;
	    ret|=func(map,bind,pos+1,res-1,false);
	    bind[pos]=-1;
	}
	for(int i=pos+1;i<bind.length;++i){
	    if(bind[i]!=-1)continue;
	    bind[pos]=i;
	    bind[i]=pos;
	    ret|=func(map,bind,pos+1,res-2,odd);
	    bind[pos]=-1;
	    bind[i]=-1;
	}
	return ret;
    }

    boolean calc(char[][] map,int[] bind){
	int H=map.length;
	int W=map[0].length;
	boolean[] used=new boolean[H];
	for(int i=0;i<H;++i){
	    if(used[i])continue;
	    for(int j=i+1;j<H;++j){
		if(used[j])continue;
		boolean flag=true;
		for(int k=0;k<W;++k){
		    flag&=map[i][k]==map[j][bind[k]];
		}
		if(flag){
		    used[i]=true;
		    used[j]=true;
		    break;
		}
	    }
	}
	for(int i=0;H%2==1&&i<H;++i){
	    if(used[i])continue;
	    boolean flag=true;
	    for(int j=0;j<W;++j){
		flag&=map[i][j]==map[i][bind[j]];
	    }
	    if(flag){
		used[i]=true;
		break;
	    }
	}
	int cnt=0;
	for(int i=0;i<H;++i){
	    if(used[i])++cnt;
	}
	return cnt==H;
    }

    void tr(Object...o){
	System.out.println(Arrays.deepToString(o));
    }
    
}


class Scanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt(){
	return (int)nextLong();
    }
}