using namespace std;
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <set>
#include <cctype>
#include <map>
#include <cmath>
#include <queue>
#include <algorithm>
#include <stack>
#include <cctype>
#include <cstring>
#include <string>
#define MAX 100100
#define PRIME 31
#define INC 100000
#define MOD 1000000007
#define PI 3.1415926535897932384
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
struct node{
int s, e, val;
};
int n, vet[MAX], res[MAX];
node seg_tree[4*MAX];
void build(int s, int e, int pos){
seg_tree[pos].s = s; seg_tree[pos].e = e;
seg_tree[pos].val = e-s+1;
if(e > s){
int mid = s+(e-s)/2;
build(s, mid, 2*pos);
build(mid+1, e, 2*pos+1);
}
}
int query(int val, int pos){
if(seg_tree[pos].s == seg_tree[pos].e) return seg_tree[pos].s;
if(val <= seg_tree[2*pos+1].val) return query(val, 2*pos+1);
return query(val-seg_tree[2*pos+1].val, 2*pos);
}
void update(int ind, int pos){
int mid = seg_tree[pos].s+(seg_tree[pos].e-seg_tree[pos].s)/2;
seg_tree[pos].val--;
if(seg_tree[pos].e == seg_tree[pos].s) return;
if(ind <= mid) update(ind, 2*pos);
else update(ind, 2*pos+1);
}
int main(){
//std::ios_base::sync_with_stdio(false);
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
int t;
cin >> t;
for(int test = 1;test <= t;test++){
cin >> n;
build(0, n-1, 1);
for(int i = 0;i < n;i++) scanf("%d", &vet[i]);
int posi;
for(int i = n-1;i >= 0;i--){
posi = query(vet[i]+1, 1);
if(!i){ cout << "Case " << test << ": " << posi+1 << endl; break; }
update(posi, 1);
}
}
return 0;
}
dXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8aW9tYW5pcD4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPGNjdHlwZT4KI2luY2x1ZGUgP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