#include using namespace std; using ll=long long; using ld=long double; using P=pair; using V=vector; #define rep(i,n) for(int i=0;i> h >> w; vector a(h,V(w)); rep(i,h) rep(j,w){ char c; cin >> c; a[i][j]=c-'a'; } string t; t+=(char)('a'+a[0][0]); set

s; s.insert(P(0,0)); while(t.size() b(0,V(3)); while(s.size()){ P p=*s.begin(); int x=p.first,y=p.second; if(x+1