#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define inf 0x7ffffff
#define pa pair<int,int>
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
inline LL read()
{
LL x=0,f=1;char ch=getchar();
while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();}
return x*f;
}
inline void write(LL a)
{
if (a<0){printf("-");a=-a;}
if (a>=10)write(a/10);
putchar(a%10+‘0‘);
}
inline void writeln(LL a){write(a);printf("\n");}
struct edge{
int to,next;
}e[100010];
int n,cnt;
int head[100010];
int fa[100010];
int dep[100010];
int son[100010][510];
int ans[512];
inline void insert(int u,int v)
{
e[++cnt].to=v;
e[cnt].next=head[u];
head[u]=cnt;
}
inline void dfs(int x)
{
son[x][0]++;
for (int i=head[x];i;i=e[i].next)
{
dfs(e[i].to);
for (int j=0;j<=dep[x];j++)
for (int k=0;k<=dep[e[i].to];k++)
ans[j^(k+1)]+=son[x][j]*son[e[i].to][k];
dep[x]=max(dep[x],dep[e[i].to]+1);
for(int j=0;j<=dep[e[i].to];j++)
son[x][j+1]+=son[e[i].to][j];
}
}
int main()
{
n=read();
for (int i=2;i<=n;i++)
fa[i]=read(),insert(fa[i],i);
dfs(1);
int mx=511;
while (!ans[mx])mx--;
for (int i=0;i<=mx;i++)printf("%d\n",ans[i]);
return 0;
}