#include<cstdio>
#include<vector>
using namespace std;
const int maxn = 100010;
struct Node{
vector<int> child;
}node[maxn];
int n, m;
int eachlevelnum[110] = {0};
void DFS(int index, int depth){
if(node[index].child.size()!=0){
for(int i=0;i<node[index].child.size();i++){
DFS(node[index].child[i], depth+1);
}
}
eachlevelnum[depth]++;
return;
}
int main(){
scanf("%d %d", &n, &m);
int nodename;
for(int i=0;i<m;i++){
scanf("%d", &nodename);
int num;
scanf("%d", &num);
for(int j=0;j<num;j++){
int nodename2;
scanf("%d", &nodename2);
node[nodename].child.push_back(nodename2);
}
}
DFS(1, 1);
int maxNode=eachlevelnum[1],maxlevel=1;
for(int i=1;i<105;i++){
if(eachlevelnum[i]>maxNode){
maxNode = eachlevelnum[i];
maxlevel = i;
}
}
printf("%d %d\n", maxNode, maxlevel);
return 0;
}