# include using namespace std; typedef long long int ll; const int maxn=1203; const ll mod=1e9 +7; int n,a[maxn],b[maxn]; ll cache[maxn][maxn]; ll dp[maxn][maxn]; bool vis[maxn][maxn]; ll fac[maxn]; ll C(int x,int y) { if(x=mod)tmp%=mod; return tmp; } ll f(int pos,int presz) { if(pos==n+1)return 1; int up=min(presz,b[pos]-pos); ll &res=dp[pos][presz]; if(vis[pos][presz])return res; vis[pos][presz]=true; res=0; for(int i=pos;i>n; for(int i=1;i<=n;i++) cin>>a[i]; b[n]=n+1; for(int i=n;i>=1;i--) { if(a[i]