#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

struct photo {
    int id, t;

    // 1. 必须重载相等比较
    bool operator==(const photo& other) const {
        return id == other.id && t == other.t;
    }
};

// 2. 特化std::hash,提供哈希规则
namespace std {
    template<>
    struct hash<photo> {
        size_t operator()(const photo& n) const {
            // 简单哈希合并:拼接两个整数哈希
            return hash<int>()(n.id) ^ (hash<int>()(n.t) << 1);
        }
    };
}

int main() {
    int n;
    cin >> n;
    // cout << n << endl;
    unordered_map<photo, int> cnt;
    while (n--) {
        int a, b;
        cin.ignore();
        while (cin >> a >> b) {
            cnt[{a, b}]++;
        }
    }
    // for (auto c : cnt)
    //     cout << c.first.id << " " << c.first.t << " " << c.second << endl;
    // cout << n << endl;
    vector<pair<photo, int>> vec(cnt.begin(), cnt.end());
    sort(vec.begin(), vec.end(), [](pair<photo, int>& x, pair<photo, int>& y){
        return x.first.t < y.first.t;
    });
    for (auto v : vec) {
        if (v.second > 1)
            cout << v.first.id << " " << v.second << " ";
    }
}
// 64 位输出请用 printf("%lld")