#include <iostream>
#include <vector>
#include <sstream>
using namespace std;
int main() {
int n;
cin>>n;
string s;
getline(cin,s);
vector<int>a[n+1];
for(int i=1; i<=n; i++){
getline(cin,s);
stringstream potok(s);
int x;
while(potok>>x){
a[x].push_back(i);
}
}
cout<<n<<endl;
for(int i=1; i<=n; i++){
for(int j:a[i])
cout<<j<<" ";
cout<<endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8c3N0cmVhbT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewoJaW50IG47CgljaW4+Pm47CglzdHJpbmcgczsKCWdldGxpbmUoY2luLHMpOwoJdmVjdG9yPGludD5hW24rMV07Cglmb3IoaW50IGk9MTsgaTw9bjsgaSsrKXsKCQlnZXRsaW5lKGNpbixzKTsKCQlzdHJpbmdzdHJlYW0gcG90b2socyk7CgkJaW50IHg7CgkJd2hpbGUocG90b2s+PngpewoJCQlhW3hdLnB1c2hfYmFjayhpKTsKCQl9Cgl9Cgljb3V0PDxuPDxlbmRsOwoJZm9yKGludCBpPTE7IGk8PW47IGkrKyl7CgkJZm9yKGludCBqOmFbaV0pCgkJY291dDw8ajw8IiAiOwoJY291dDw8ZW5kbDsKCX0KCQogICAgcmV0dXJuIDA7Cn0=