#include<cstdio>
#include<iostream>
#define NIL -1
using namespace std;
struct Node{int l, p, r, s, deg;};
int D[30], H[30];
Node T[30];
void setDepth(int r, int d)
{
  if(r == NIL) return;
  D[r] = d;
  setDepth(T[r].l, d+1);
  setDepth(T[r].r, d+1);
}

int setHeight(int u)
{
  int h1, h2;
  h1 = h2 = 0;
  if(T[u].l != NIL)
    h1 = setHeight(T[u].l) + 1;
  if(T[u].r != NIL)
    h2 = setHeight(T[u].r) + 1;
  return H[u] = max(h1, h2);
}

void print(int i)
{
  printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ", i, T[i].p, T[i].s, T[i].deg, D[i], H[i]);
  if(T[i].p == NIL)
    printf("root\n");
  else if(T[i].l == NIL && T[i].r == NIL)
    printf("leaf\n");
  else printf("internal node\n");
}
int main()
{
  int n;
  int left, right, root, temp, v;
  scanf("%d", &n);
  for(int i=0; i<n; i++)
  {
    T[i].l = T[i].p = T[i].r = T[i].s = NIL;
    T[i].deg = 0;
  }
  for(int i=0; i<n; i++)
  {
    scanf("%d", &v);
    scanf("%d%d", &left, &right);
    T[v].l = left; T[v].r = right;
    T[left].p = T[right].p = v;
    T[left].s = right; T[right].s = left;
    if(left != NIL)
      T[v].deg++;
    if(right != NIL)
      T[v].deg++;
  }
  for(int i=0; i<n; i++)
  {
    if(T[i].p == NIL) root = i;
  }
  setDepth(root, 0);
  setHeight(root);
  for(int i=0; i<n; i++)
    print(i);

  return 0;
}

