#include<iostream>
using namespace std;
struct student
{
long long id;//char id[18];
int m;
int n;
};
int main()
{
student stu[1001];
int a;
int b;
int c[1001];
cin>>a;
for(int i=0;i<a;i++)
{
cin>>stu[i].id>>stu[i].m>>stu[i].n;
}
cin>>b;
for(int j=0;j<b;j++)
{
cin>>c[j];
for(int i=0;i<a;i++)
{
if(c[j]==stu[i].m)
{
cout<<stu[i].id<<" "<<stu[i].n<<endl;
}
}
}
return 0;
}
https://pintia.cn/problem-sets/994805260223102976/problems/994805281567916032