#include<iostream>
using namespace std;
int main(int argc, char** argv)
{
int test_case;
cin>>test_case;
for(int b = 1; b <= test_case; b++)
{
int temp;
temp = -1;
for (int i = 0; i <= 10; i ++ ){
int a;
cin >>a;
if (a > temp)
temp = a;
}
cout << "#" << b << " " << temp << endl;
}
return 0;//정상종료시 반드시 0을 리턴해야합니다.
}