#include <iostream>
#include <vector>
using namespace std;
vector<int> v[100];
int maxdepth = 0, level[100] = {0};
bool visited[100] = {false};
void dfs(int index, int depth){
if(!visited[index]) level[depth]++;
visited[index] = true;
if(v[index].size() == 0){
if(depth > maxdepth) maxdepth = depth;
return;
}
for (int i = 0; i < v[index].size(); i++)
dfs(v[index][i], depth + 1);
}
int main(){
int n, m;
cin >> n >> m;
for (int i = 0; i < m; i++) {
int f, k;
cin >> f >> k;
for (int j = 0; j < k; j++) {
int t;
cin >> t;
v[f].push_back(t);
}
}
dfs(1, 0);
int maxnum = 0, maxg = 0;
for (int i = 0; i <= maxdepth; i++) {
if(level[i] > maxnum){ maxnum = level[i]; maxg = i + 1;}
}
cout << maxnum << ' ' << maxg << endl;
return 0;
}