#include "graph.h"
#include <bits/stdc++.h>
using namespace std;
namespace my_code{
int n = 0, d[210], e[210][210], dep[210], fa[210][210], dis[210][210], ans[210];
int bk[210][210];
int dfs1(int x, int fa0){
int u = ++n, i, j, v;
dep[u] = x; fa[u][1] = fa0;
for(i = 2; fa[u][i - 1] > 1; i++) fa[u][i] = fa[fa[u][i - 1]][1];
d[u] = NumberOfRoads();
for(i = 1; i <= d[u]; i++){
if(bk[u][i] < 0) continue;
Move(i, 3);
j = LastRoad();
if(Color() == 1){
e[u][i] = v = dfs1(x + 1, u);
bk[u][i] = 1; bk[v][j] = -1;
Move(j, 2);
}else if(Color() == 3){
e[u][i] = 0; bk[u][i] = 2;
Move(j, 3);
}else{
bk[u][i] = -2;
Move(j, 2);
}
}
return u;
}
void dfs2(int u, int x){
int i, j, w = dep[u] % (x * 3) / x + 1;
// printf("%d %d %d\n", u, x, w);
for(i = 1; i <= d[u]; i++){
if(bk[u][i] < 0) continue;
Move(i, w); j = LastRoad();
if(bk[u][i] == 1){
dfs2(e[u][i], x);
}else{
e[u][i] += (Color() - 1) * x;
}
Move(j, Color());
}
}
void Inspect(int R){
memset(bk, 0, sizeof(bk));
int i, j, p;
dfs1(0, 1);
// for(i = 1; i <= n; i++){
// printf("%d %d %d %d\n", i, d[i], dep[i], fa[i][1]);
// for(j = 1; j <= d[i]; j++) printf(" (%d,%d,%d)", j, e[i][j], (int)bk[i][j]);
// printf("\n");
// }
for(i = 1, j = 1; i <= 5; i++, j *= 3){
dfs2(1, j);
}
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++) dis[i][j] = R + 1;
}
for(i = 1; i <= n; i++){
for(j = 1; j <= d[i]; j++){
if(bk[i][j] == 1){
dis[i][e[i][j]] = dis[e[i][j]][i] = 1;
}else if(bk[i][j] == 2){
p = fa[i][dep[i] - e[i][j]];
dis[i][p] = dis[p][i] = 1;
}
}
}
for(p = 1; p <= n; p++){
for(i = 1; i <= n; i++){
for(j = 1; j <= n; j++) dis[i][j] = min(dis[i][j], dis[i][p] + dis[p][j]);
}
}
for(i = 1; i <= R; i++) ans[i] = 0;
for(i = 1; i <= n; i++){
for(j = i + 1; j <= n; j++) ans[dis[i][j]]++;
}
for(i = 1; i <= R; i++){
Answer(i, ans[i]);
}
}
}
void Inspect(int R){
my_code::Inspect(R);
}