int n,m,k,a[2d3][2d3];Mint r;Combc;{rd(n,m,a(n,m));rep(i,n)rep(j,m)r+=c.C(k-2,i)*(c.H(k-1,a[i][j]-1)+2c.H(k,a[i][j]-1)-c.H(k,a[i+1][j]-1)-c.H(k=i+j+2,a[i][j+1]-1));wt(r);}