#include <iostream>
#include <cstring>
using namespace std ;
/**此结构体包括证件号和时间
* 早晚签到都是证件号和时间
*/
struct node{
string s, t; //证件号和时间
}ft, lt;
int main(){
int N, M;
string ps,pft, plt; //证件号,早起时间,晚上时间
cin>>N;
while (N--){
cin>>M;
M--;
cin>>ps>>ft.t>>lt.t;
ft.s=lt.s = ps; //
while (M--){
cin>>ps>>pft>>plt; //输入第二个人的证件号和时间
if (pft < ft.t){ //如果比第一个人来的早
ft.s = ps; //把第二个人的证件号及时间放到第一个人的结构体中
ft.t = pft;
}
if (plt > lt.t) { //如果比第一个人走的晚
lt.s = ps; //把第二个人的证件号及时间放到第一个人的结构体中
lt.t = plt;
}
}
cout<<ft.s<<" "<<lt.s<<endl;
}
#include <cstring>
using namespace std ;
/**此结构体包括证件号和时间
* 早晚签到都是证件号和时间
*/
struct node{
string s, t; //证件号和时间
}ft, lt;
int main(){
int N, M;
string ps,pft, plt; //证件号,早起时间,晚上时间
cin>>N;
while (N--){
cin>>M;
M--;
cin>>ps>>ft.t>>lt.t;
ft.s=lt.s = ps; //
while (M--){
cin>>ps>>pft>>plt; //输入第二个人的证件号和时间
if (pft < ft.t){ //如果比第一个人来的早
ft.s = ps; //把第二个人的证件号及时间放到第一个人的结构体中
ft.t = pft;
}
if (plt > lt.t) { //如果比第一个人走的晚
lt.s = ps; //把第二个人的证件号及时间放到第一个人的结构体中
lt.t = plt;
}
}
cout<<ft.s<<" "<<lt.s<<endl;
}
return 0;
}