#include <iostream>
#include <string>
using namespace std;
struct Student {
string fam, name;
int m, f, i;
};
int main() {
int n;
cin >> n;
Student a[n];
for(int i = 0; i < n; i++) {
cin >> a[i].fam >> a[i].name >> a[i].m >> a[i].f >> a[i].i;
}
for(int i = 0; i < n; i++) {
if (a[i].m > 3 && a[i].f > 3 && a[i].i > 3) {
cout << a[i].fam << " " << a[i].name << endl;
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IFN0dWRlbnQgewogICAgc3RyaW5nIGZhbSwgbmFtZTsKICAgIGludCBtLCBmLCBpOwp9OwoKaW50IG1haW4oKSB7CiAgICBpbnQgbjsKICAgIGNpbiA+PiBuOwogICAgU3R1ZGVudCBhW25dOwogICAgCiAgICBmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgY2luID4+IGFbaV0uZmFtID4+IGFbaV0ubmFtZSA+PiBhW2ldLm0gPj4gYVtpXS5mID4+IGFbaV0uaTsKICAgIH0KICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICBpZiAoYVtpXS5tID4gMyAmJiBhW2ldLmYgPiAzICYmIGFbaV0uaSA+IDMpIHsKICAgICAgICAgICAgY291dCA8PCBhW2ldLmZhbSA8PCAiICIgPDwgYVtpXS5uYW1lIDw8IGVuZGw7CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIDA7Cn0K