#pragma comment(linker, "/STAcK:1024000000,1024000000") #include #include #include #include #include #include #include #include #include #include #include #include #include #define INF 0X3F3F3F3F #define N 10005 #define M 200005 #define LL long long #define ULL unsigned long long #define FF(i, a, b) for(int i = a; i <= b; ++i) #define RR(i, a, b) for(int i = a; i >= b; --i) #define FJ(i, a, b) for(int i = a; i < b; ++i) #define SC(x) scanf("%d", &x) #define SCC(x, y) scanf("%d%d", &x, &y) #define SS(x) scanf("%s", x) #define PR(x) printf("%d\n", x) #define PII pair #define PLL pair #define MP make_pair #define PB push_back #define IN freopen("in.txt", "r", stdin) #define OUT freopen("out.txt", "w", stdout) using namespace std; inline void II(int &n){char ch = getchar(); n = 0; bool t = 0; for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1; for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;} inline void OO(int a){if(a < 0) {putchar('-'); a = -a;} if(a >= 10) OO(a / 10); putchar(a % 10 + '0');} const int MOD = 1e9 + 7; int a[N], n; LL c[N], ans[N], f[2][N]; void add(int x, LL d){ for(; x <= n; x += x & (-x)){ c[x] += d; c[x] %= MOD; } } LL sum(int x){ LL ret = 0; for(; x; x &= x - 1) (ret += c[x]) %= MOD; return ret; } int main(){ // IN; int _; SC(_); FF(CA, 1, _){ scanf("%d", &n); FF(i, 1, n){ II(a[i]); f[0][i] = 1; } memset(ans, 0, sizeof ans); ans[1] = n; int cur = 1; FF(l, 2, n){ FF(i, 1, n){ LL tmp = sum(a[i] - 1); ans[l] += tmp; add(a[i], f[cur ^ 1][i]); f[cur][i] = tmp; } memset(c, 0, sizeof c); cur ^= 1; if(ans[l] == 0) break; } printf("Case #%d:", CA); FF(i, 1, n) printf(" %I64d", ans[i] % MOD); puts(""); } return 0; }