#include<bits/stdc++.h>
using namespace std;
int main(void){
int n;
cin >> n;
vector<pair<string, int>> vec;
for(int i = 1 ; i <= n ; i++){
for(int j = 0 ; j < 10 ; j++){
string str;
int num;
cin >> str >> num;
vec.push_back(make_pair(str, num));
} int num = 0;
for(auto iter : vec){
if(iter.second > num){
num = iter.second;
}
}
cout << "Case #" << i << ":" << endl;
for(auto iter : vec){
if(iter.second == num){
cout << iter.first << endl;
}
}
}
}
vector<pair<string, int>> vec;
這一行放到第一層for迴圈裡面,或者是在測資之間要清空