#include #define to edge[i].v #define mp make_pair #define rint register int #define debug(x) cerr<<#x<<"="< pii; const int mod=1e9+7; int a[500][N],f[N][500],s[N],sum[N],b[N],n; inline void add(int id,int x,int y) {for(rint i=x;i<=n;i+=lowbit(i))(a[id][i]+=y)%=mod;} inline int query(int id,int x) {int A=0;for(rint i=x;i;i-=lowbit(i))(A+=a[id][i])%=mod;return A;} int main() { int t; cin>>t; for(rint T=1;T<=t;T++) { memset(a,0,sizeof(a)); memset(s,0,sizeof(s)); memset(sum,0,sizeof(sum)); int cur,lis=0; scanf("%d",&n); for(rint i=1;i<=n;i++) scanf("%d",&b[i]),s[i]=1e9; for(rint i=1;i<=n;i++) { lis=max(lis,cur=upper_bound(s,s+n+1,b[i])-s); s[cur]=min(s[cur],b[i]); } for(rint i=1;i<=n;i++) { f[i][1]=1; add(1,b[i],1); sum[1]++; for(rint j=2;j<=min(i,lis);j++) f[i][j]=query(j-1,b[i]-1),add(j,b[i],f[i][j]),(sum[j]+=f[i][j])%=mod; } printf("Case #%d: ",T); for(rint i=1;i<=n;i++) printf(i==n?"%d\n":"%d ",sum[i]); } return 0; }