#include "bits/stdc++.h" using namespace std; #define print(x) cout< PI; typedef pair V; typedef vector VE; const ll mod = 100000000000; using namespace std; int main() { int h,w; cin>>h>>w; vector s(h); string ans="NO"; bool flag=true; REP(i,h){ cin>>s[i]; } for(int i=-h;ih||nl>w||nl<0||s[k][l]!=s[nk][nl]){ flag=false; goto stop; } c[k][l]=c[nk][nl]='.'; } } } stop: ans=flag?"YES":"NO"; } } print(ans); }