#include using namespace std; #define y1 y114514 #define pb push_back #define mkp make_pair #define fi first #define se second #define all(a) a.begin(), a.end() typedef pair pii; typedef unsigned long long ull; typedef long long ll; const int M = 1000000007; const int maxn = 10005, maxk = 300; int T, n, ca; int a[maxn], c[maxn], d[maxk][maxn]; int ans[maxn]; int ask(int x){ int res = 0; for(; x; x -= x & -x) res = max(res, c[x]); return res; } void modify(int x, int v){ for(; x <= n; x += x & -x) c[x] = max(c[x], v); } int ask(int l, int x){ int res = 0; for(; x; x -= x & -x) res = (res + d[l][x]) % M; return res; } void add(int l, int x, int v){ for(; x <= n; x += x & -x) d[l][x] = (d[l][x] + v) % M; } int main(){ scanf("%d", &T); while(T--){ scanf("%d", &n); for(int i = 1; i <= n; ++i) scanf("%d", a + i); memset(c, 0, sizeof(c)); for(int l = 1; l <= 300; ++l) memset(d[l], 0, sizeof(int) * (n + 1)); memset(ans, 0, sizeof(ans)); for(int i = 1; i <= n; ++i){ int maxL = ask(a[i]); modify(a[i], maxL + 1); for(int l = maxL; l >= 1; --l){ int now = ask(l, a[i]); add(l + 1, a[i], now); ans[l + 1] = (ans[l + 1] + now) % M; } add(1, a[i], 1); } ans[1] = n; printf("Case #%d:", ++ca); for(int i = 1; i <= n; ++i) printf(" %d", ans[i]); puts(""); } return 0; }