# include # define IL inline # define RG register # define Fill(a, b) memset(a, b, sizeof(a)) using namespace std; typedef long long ll; IL int Input(){ RG char c = getchar(); RG int x = 0, z = 1; for(; c < '0' || c > '9'; c = getchar()) z = c == '-' ? -1 : 1; for(; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); return x * z; } const int maxn(10005); const int mod(1e9 + 7); int n, p[maxn], f[maxn], c[maxn]; IL void Upd(RG int &x, RG int y){ x += y; if(x >= mod) x -= mod; } IL void Add(RG int x, RG int v){ for(; x <= n; x += x & -x) Upd(c[x], v); } IL int Query(RG int x){ RG int ret = 0; for(; x; x -= x & -x) Upd(ret, c[x]); return ret; } int main(RG int argc, RG char* argv[]){ for(RG int nw = 1, tt = Input(); nw <= tt; ++nw){ printf("Case #%d: ", nw); Fill(c, 0), Fill(f, 0), n = Input(); for(RG int i = 1; i <= n; ++i) f[i] = 1, p[i] = Input(); printf("%d", n); for(RG int i = 2; i <= n; ++i){ RG int ans = 0; if(i > 300) printf(" 0"); else{ for(RG int j = 1; j <= n; ++j) c[j] = 0; for(RG int j = 1; j <= n; ++j){ RG int ret = Query(p[j] - 1); Upd(ans, ret); Add(p[j], f[j]), f[j] = ret; } printf(" %d", ans); } } puts(""); } return 0; }