//迷雾森林 //dp优化 //快读+图和dp存一起 //注意取模 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int p=2333; inline int read() { int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1; for (;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f; } ll f[3010][3010]; int main() { // ios::sync_with_stdio(false); // cin.tie(0);cout.tie(0); int n,m; n=read();m=read(); for(int i=1;i<=n;i++) for(int j=1; j<=m ;j++) f[i][j]=read(); for(int i=n;i>= 1;i--) for(int j=1;j<=m;j++) { if(f[i][j]==1) {f[i][j]=0;continue;}//如果走不了,continue,并把路数改为0 if(i==n && j==2) f[i][j]=1; //起点相邻的两点初始化 else if(i==n-1 && j==1) f[i][j]=1; else f[i][j]=(f[i+1][j]+f[i][j-1])%p; //dp注意取模 } cout<<f[1][m]<<endl; }