#include<iostream>
using namespace std;
int main(int argc, char** argv)
{
int test_case;
int T;
cin>>T;
for(test_case = 1; test_case <= T; ++test_case)
{
int a = 0;
for(int i=0; i<10; i++)
{
int num;
cin >> num;
if(num>a)
{
a = num;
}
}
cout << "#" << test_case << " " << a << "\n";
}
return 0;
}