#include using namespace std; using ll=long long; using P=pair; int main(){ ll h,w; cin>>h>>w; vector> a(h,vector(w)); for(ll i=0;i>a[i][j]; } } vector> co(h,vector(w,-1)); co[0][0]=1; co[h-1][w-1]=0; vector dx={0,0,-1,1}; vector dy={-1,1,0,0}; set k1,k2; map rev; k1.insert(a[0][1]); k1.insert(a[1][0]); k2.insert(a[h-2][w-1]); k2.insert(a[h-1][w-2]); for(ll i=0;i