#include <iostream>
#include <stack>
#include <algorithm>
using namespace std;
#define N 101
bool map[N][N];
int dfn[N],low[N],belong[N],in[N],out[N];
bool instack[N];
stack<int> sta;
int n,index,cnt;
void Init()
{
memset(map,false,sizeof(map));
memset(instack,false,sizeof(instack));
memset(dfn,0,sizeof(dfn));
memset(low,0,sizeof(low));
memset(in,0,sizeof(in));
memset(out,0,sizeof(out));
int temp;
for(int i=1;i<=n;i++ )
{
while(cin>>temp && temp!=0)
{
map[i][temp]=true;
}
}
index = 0;
cnt=0;
while(!sta.empty())
sta.pop();
}
int min(int a,int b)
{
return a<b?a:b;
}
int max(int a,int b)
{
return a>b?a:b;
}
void Tarjan(int u)
{
dfn[u]=low[u]=++index;
sta.push(u);instack[u]=true;
for(int v=1;v<=n;v++)
{
if(!map[u][v]) continue;
if(!dfn[v])
{
Tarjan(v);
low[u]=min(low[u],low[v]);
}
else if(instack[v])
{
low[u]=min(low[u],dfn[v]);
}
}
if(dfn[u]==low[u])
{
cnt++;
int temp;
do{
temp=sta.top();
sta.pop();
belong[temp]=cnt;
instack[temp]=false;
}while(temp!=u);
}
}
void Output()
{
int inCount=0,outCount=0;
for( int u=1;u<=n;u++ )
{
for( int v=1;v<=n;v++)
{
if(!map[u][v]) continue;
if(belong[u]!=belong[v])//u和v不在一个强连通分量中
{
out[belong[u]]++;
in[belong[v]]++;
}
}
}
for( int i=1;i<=cnt;i++ )
{
if(in[i]==0)
inCount++;
if(out[i]==0)
outCount++;
}
if(cnt==1)//即该图是强连通图。第二问的结果应该是0,而不是1。
cout<<1<<endl<<0<<endl;
else
{
cout<<inCount<<endl;
cout<<max(inCount,outCount)<<endl;
}
}
int main()
{
while(cin>>n)
{
Init();
for(int i=1;i<=n;i++)
{
if(!dfn[i])
Tarjan(i);
}
Output();
}
return 0;
}