/******************************************** *Author* :ZZZZone *Created Time* : 六 8/ 4 23:11:45 2018 *********************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define debug(x) std::cerr << #x << " = " << (x) << std::endl typedef pair PII; typedef long long LL; typedef unsigned long long ULL; inline void OPEN(string s){ freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } const int MAXN = 10000; const int Pt = 1e9 + 7; int dp[MAXN+5][305]; int bitsum[305][MAXN+5]; int a[MAXN+5]; int n; inline int lowbit(int x){return (x & (-x)); } inline int Getsum(int p, int id){ int res = 0; for(int i = p; i > 0; i -= lowbit(i)){ res = (res + bitsum[id][i]) % Pt; } return res; } inline void Add(int p, int id, int val){ for(int i = p; i <= n; i += lowbit(i)){ bitsum[id][i] = (bitsum[id][i] + val) % Pt; } } inline void Init(){ scanf("%d", &n); for(int i = 1; i <= n; i++) scanf("%d", &a[i]); } void Solve(){ for(int i = 1; i <= n; i++){ dp[i][1] = 1; for(int j = 1; j <= i; j++){ dp[i][j] = (dp[i][j] + Getsum(a[i]-1, j-1)) % Pt; if(dp[i][j] == 0) break; Add(a[i], j, dp[i][j]); } } } int main() { int T; scanf("%d", &T); for(int cas = 1; cas <= T; cas++){ printf("Case #%d:", cas); Init(); Solve(); for(int i = 1; i <= n; i++){ int ans = 0; if(i <= 300){ for(int j = 1; j <= n; j++) ans = (ans + dp[j][i]) % Pt; } printf(" %d", ans); } printf("\n"); memset(dp, 0, sizeof(dp)); memset(bitsum, 0, sizeof(bitsum)); } return 0; }