#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
struct node{
int to,nxt;
}d[N*2];int head[N*2],tot=0;
void add(int a,int b){
d[++tot]={b,head[a]};head[a]=tot;
}
int low[N],dfn[N],Stack[N],belong[N];
int Index,top,scc,num[N];
bool instack[N];
void tarjan(int u){
int v;
low[u]=dfn[u]=++Index;
Stack[top++]=u;
instack[u]=true;
for(int i=head[u];i;i=d[i].nxt){
v=d[i].to;
if(!dfn[v]){
tarjan(v);
if(low[u]>low[v]){
low[u]=low[v];
}
}else if(instack[v]&&low[u]>dfn[v]){
low[u]=low[v];
}
}
if(low[u]==dfn[u]){
scc++;
do{
v=Stack[--top];
instack[v]=false;
belong[v]=scc;num[scc]++;
}while(v!=u);
}
return ;
}
void solve(int n){
memset(dfn,0,sizeof dfn);
memset(instack,false,sizeof instack);
memset(num,0,sizeof num);
Index=scc=top=0;
for(int i=1;i<=n;i++){
if(!dfn[i]) tarjan(i);
}
}
void init(){
tot=0;memset(head,0,sizeof head);
}
int n,m;
int in[N],out[N];
int main(){
scanf("%d",&n);
init();
for(int i=1;i<=n;i++){
int x;
while(scanf("%d",&x)){
if(x==0) break;
add(i,x);
}
}
solve(n);
for(int i=1;i<=n;i++){
for(int j=head[i];j;j=d[j].nxt){
int to=d[j].to;
int bx=belong[i],by=belong[to];
// cout<<i<<" "<<to<<" ";
// cout<<bx<<" "<<by<<endl;
if(bx!=by){
in[by]++;out[bx]++;
}
}
}
// cout<<scc<<endl;
if(scc==1){
cout<<1<<endl<<0<<endl;
return 0;
}
int cnt=0,cnt2=0;
for(int i=1;i<=scc;i++){
if(in[i]==0) cnt++;
if(out[i]==0) cnt2++;
}
cout<<cnt<<endl<<max(cnt,cnt2)<<endl;
}