Note
Code
#include<bits/stdc++.h>
using namespace std;
int counts[100]={0};
struct Tree{
vector<int> node;
int level;
}tree[100];
void bfs(int root){
queue<int> q;
q.push(root);
tree[root].level=1;
while(!q.empty()){
int data=q.front();
q.pop();
counts[tree[data].level]++;
for(int i=0;i<tree[data].node.size();i++){
q.push(tree[data].node[i]);
tree[tree[data].node[i]].level=tree[data].level+1;
}
}
}
int main(){
#ifndef ONLINE_JUDGE
freopen("data.txt","r",stdin);
#endif
int n,m;
scanf("%d %d",&n,&m);
int num,k,child;
for(int i=0;i<m;i++){
scanf("%d %d",&num,&k);
for(int j=0;j<k;j++){
scanf("%d",&child);
tree[num].node.push_back(child);
}
}
bfs(1);
int max=*max_element(counts,counts+100);
int index=max_element(counts,counts+100)-counts;
cout<<max<<" "<<index;
return 0;
}