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