2019年2月17日
21:13
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cstring>
using namespace std;
typedef struct P
{
int d;
vector<int> son;
}Person;
Person p[105];
int n, m;
void bfs()
{
queue<int> q;
q.push(1);
p[1].d = 1;
while(!q.empty())
{
int y = q.front();
//cout << y << " ";
q.pop();
for(int i = 0; i < p[y].son.size(); i++)
{
int x = p[y].son[i];
q.push(x);
p[x].d = p[y].d + 1;
}
}
//cout << endl;
}
int main()
{
while(cin >> n >> m)
{
int k, fa, son;
for(int i = 0 ; i < m; i++)
{
cin >> fa >> k;
for(int i = 0; i < k; i++)
{
cin >> son;
p[fa].son.push_back(son);
}
}
bfs();
map<int, int> mp;
map<int, int> ::iterator it;
for(int i = 1 ; i <= n; i++)
{
//cout <<p[i].d << endl;
mp[p[i].d]++;
}
int d = 1, ma = 1;
for(it = mp.begin(); it != mp.end(); it++)
{
if(it->second > ma)
{
ma = it->second;
d = it->first;
}
}
printf("%d %d\n", ma, d);
}
return 0;
}