#include <cstdio>
#include <algorithm>
#include <iostream>

using namespace std;

int n, nTest;
int a[111], ret[111];
pair<int, int> b[111];

int main() {
    freopen("cubes.in", "r", stdin);
//    freopen("cubes.out", "w", stdout);
    scanf("%d", &nTest);
    for(int test = 1; test <= nTest; test++) {
        scanf("%d", &n);
        for(int i = 1; i <= n; i++) {
            scanf("%d", a+i);
            b[i] = make_pair(i*(n-i+1), -i);
        }
        sort(a+1, a+1+n, greater<int>());
        sort(b+1, b+1+n);
        for(int i = 1; i <= n; i++) 
            ret[-b[i].second] = a[i];
        printf("Case %d:\n", test);
        for(int i = 1; i <= n; i++) printf("%d ", ret[i]);
        if (test < nTest) printf("\n");
    }
    return 0;
}