#include <bits/stdc++.h>

#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#define pb push_back
typedef long long ll;
using namespace std;

vector <int> edge[100005];
bool view[100005] = {0};
ll in[100005] = {0},out[100005] = {0},h[100005] = {0};

ll dfs(int x){
	view[x] = true;
	if(out[x]==0)return 0;
	ll ans = -1;
	for(int i=0;i<(int)edge[x].size();i++){
		int todo = edge[x][i];
		if(!view[todo]){
			ans = max(ans,dfs(todo)+1);
		}
	}
	h[x] = ans;
	return h[x];
}


/********** Main()  function **********/
int main(){
	IOS();	
	//create the graph
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		int k;cin>>k;
		while(k--){
			int tmp;cin>>tmp;
			in[tmp]++;out[i]++;
			edge[i].pb(tmp);
		}
	}
	//find the root
	int root = 0;
	for(int i=1;i<=n;i++){
		if(!in[i]){
			root = i;
			break;
		}
	}
	dfs(root);
	//output ans
	ll sum = 0;
	for(int i=1;i<=n;i++){
		sum+=h[i];
	}
	cout << root << endl << sum << endl;
	return 0;
}

ZJ
pixiv