#include using namespace std; using Int = long long; typedef vector arr; typedef vector mat; inline arr mul(const mat &a,arr &b){ arr res(b.size(),0); for(Int i=0;i<(Int)b.size();i++) for(Int j=0;j<(Int)a[i].size();j++) res[i]+=a[i][j]*b[j]; return res; } inline mat mul(const mat &a,const mat &b){ mat res(a.size(),arr(b[0].size(),0)); for(Int i=0;i<(Int)a.size();i++) for(Int j=0;j<(Int)b[0].size();j++) for(Int k=0;k<(Int)b.size();k++) res[i][j]+=a[i][k]*b[k][j]; return res; } inline mat mat_pow(mat a,Int n){ mat res(a); for(Int i=0;i<(Int)a.size();i++) for(Int j=0;j<(Int)a[i].size();j++) res[i][j]=(i==j); while(n){ if(n&1) res=mul(a,res); a=mul(a,a); n>>=1; } return res; } struct Precision{ Precision(){ cout<>h>>w>>t; Int sy,sx,gy,gx; cin>>sy>>sx>>gy>>gx; vector s(h); for(Int i=0;i>s[i]; Int N=h*w; auto idx=[&](Int y,Int x){return y*w+x;}; mat m(N,arr(N,0)); Int dy[]={1,-1,0,0}; Int dx[]={0,0,1,-1}; for(Int i=0;i