#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int maxn = 110;
vector<int> node[maxn];
int n, m;
int id, k, temp;
int level[maxn] = { 0 };
int maxdepth = 0;
void dfs(int root,int depth)
{
if (depth > maxdepth) maxdepth = depth;
level[depth]++;
if (node[root].size() == 0) return;
for (int i = 0; i < node[root].size(); i++)
{
dfs(node[root][i], depth + 1);
}
}
int main()
{
scanf("%d%d", &n, &m);
for (int j = 0; j < m; j++)
{
scanf("%d %d", &id, &k);
for (int i = 0; i < k; i++)
{
scanf("%d", &temp);
node[id].push_back(temp);
}
}
dfs(1, 1);
int max = -1,maxl=0;
for (int i = 0; i <= maxdepth; i++)//注意这里是要取等号,不要习惯性的不写等号
{
if (level[i] > max)
{
max = level[i];
maxl = i;
}
}
printf("%d %d", max, maxl);
return 0;
}