#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[1001][1001];
vector<pair<int, int>> edge;
int main(){
cin >> n;
cin.ignore();
for(int i = 1; i <= n; i++){
string s, num;
getline(cin, s);
stringstream ss(s);
while(ss >> num){
edge.push_back({i, stoi(num)});
}
}
for(auto it : edge){
cout << it.first << " " << it.second << endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbiwgbTsKaW50IGFbMTAwMV1bMTAwMV07CnZlY3RvcjxwYWlyPGludCwgaW50Pj4gZWRnZTsKaW50IG1haW4oKXsKCWNpbiA+PiBuOwoJY2luLmlnbm9yZSgpOwoJZm9yKGludCBpID0gMTsgaSA8PSBuOyBpKyspewoJCXN0cmluZyBzLCBudW07CgkJZ2V0bGluZShjaW4sIHMpOwoJCXN0cmluZ3N0cmVhbSBzcyhzKTsKCQl3aGlsZShzcyA+PiBudW0pewoJCQllZGdlLnB1c2hfYmFjayh7aSwgc3RvaShudW0pfSk7CgkJfQoJfQoJZm9yKGF1dG8gaXQgOiBlZGdlKXsKCQljb3V0IDw8IGl0LmZpcnN0IDw8ICIgIiA8PCBpdC5zZWNvbmQgPDwgZW5kbDsKCX0KCXJldHVybiAwOwp9Cgo=