WA90pts,WA#11
#include<bits/stdc++.h>
using namespace std;
const int N=110,M=N*N;
int n,m,ans1,ans2,cnt,tot,top,dfn[N],low[N],st[N],inst[N],scc[N],u[M],v[M],in[N],out[N];vector<int>g[N];
void tarjan(int x){
dfn[x]=low[x]=++cnt,st[top++]=x,inst[x]=1;
for(int y:g[x])if(!inst[y])tarjan(y),low[x]=min(low[x],low[y]);else if(inst[y]==1)low[x]=min(low[x],dfn[y]);
if(dfn[x]==low[x]){
++tot;
do{--top,scc[st[top]]=tot,inst[st[top]]=-1;}while(st[top]!=x);
}
}int main(){
cin>>n;
for(int i=1,x;i<=n;i++)while(cin>>x&&x)g[x].push_back(i),++m,u[m]=i,v[m]=x;
for(int i=1;i<=n;i++)if(!dfn[i])tarjan(i);
for(int i=1;i<=m;i++)if(scc[u[i]]!=scc[v[i]])++in[scc[v[i]]],++out[scc[u[i]]];
if(tot==1)cout<<"1\n0";
else{
for(int i=1;i<=tot;i++)in[i]||++ans1,out[i]||++ans2;
cout<<ans1<<'\n'<<ans2;
}return 0;
}