#include <iostream>
using namespace std;
class person {
  public:
    string no;
    string name;
    string sex;
    int age;
  public:
    void say() {
        cout << no << " " << name << " " << sex << " " << age << endl;
    }
};
int main() {
    int h;
    cin >> h;
    while (h--) {
        int n;
        cin >> n;
        person arr[n];
        person p;
        string no, name, sex;
        int age;
        for (int i = 0; i < n; i++) {
            cin >> no >> name >> sex >> age;
            p.no = no;
            p.name = name;
            p.sex = sex;
            p.age = age;
            arr[i] = p;
        }
        //开始查找
        string k;
        cin >> k;
        for (auto a : arr)
            if (a.no == k)
                a.say();
    }

}
// 64 位输出请用 printf("%lld")

KY27 查找学生信息几乎一样,直接改的