#include <bits/stdc++.h>
using namespace std;
const int N = 110, M = N * N;
int n;
int h[N], e[M], ne[M], idx;
int dnf[N], low[N], timestamp;
int stk[N], top;
bool in_stk[N];
int id[N], scc_cnt;
int ao[N], ai[N];
void add(int a, int b)
{
e[idx] = b, ne[idx] = h[a], h[a] = idx ++;
}
void tarjan(int u)
{
dnf[u] = low[u] = ++ timestamp;
stk[++ top] = u, in_stk[u] = true;
for (int i = h[u]; ~i; i = ne[i])
{
int j = e[i];
if (!dnf[j])
{
tarjan(j);
low[u] = min(low[u], low[j]);
}
else if (in_stk[j])
low[u] = min(low[u], dnf[j]);
}
if (low[u] == dnf[u])
{
++ scc_cnt;
int y;
do{
y = stk[top --];
in_stk[y] = false;
id[y] = scc_cnt;
} while (y != u);
}
}
int main(void)
{
cin >> n;
memset(h, -1, sizeof h);
for (int i = 1; i <= n; i ++)
{
int a;
while (scanf("%d", &a), a)
{
add(i, a);
}
}
for (int i = 1; i <= n; i ++)
if (!dnf[i])
tarjan(i);
for (int i = 1; i <= n; i ++)
for (int j = h[i]; ~j; j = ne[j])
{
int k = e[j];
int a = id[i], b = id[k];
if (a != b)
ao[a] ++, ai[b] ++;
}
int ans1 = 0, ans2 = 0;
for (int i = 1; i <= scc_cnt; i ++)
{
if (!ai[i]) ans1 ++;
if (!ao[i]) ans2 ++;
}
cout << ans1 << endl;
if (scc_cnt == 1) puts("0");
else printf("%d\n", max(ans1, ans2));
}