#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int par[30], bro[30], ch[30][2], dep[30], hei[30], chs[30];
int findGrandPar(int v){
  if(par[v] == -1){
    return v;
  }
  return findGrandPar(par[v]);
}

int f(int v) {
  int h = 0;
  FOR(i,0,2){
    if(ch[v][i]!=-1){
      chs[v]++;
      dep[ch[v][i]] = dep[v] + 1;
      h = max(f(ch[v][i])+1, h);
    }
  }
  return hei[v] = h;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  FOR(i,0,30) dep[i] = par[i] = bro[i] = -1;
  FOR(i,0,n){
    int id, l, r;
    cin >> id >> l >> r;
    ch[id][0] = l;
    ch[id][1] = r;
    bro[l] = r;
    bro[r] = l;
    if(l!=-1){
      par[l] = id;
    }
    if(r!=-1){
      par[r] = id;
    }
  }
  int v = findGrandPar(0);
  dep[v] = 0;
  f(v);
  FOR(i,0,n){
    string s = "";
    if(dep[i] == 0) s = "root";
    else if(hei[i] == 0) s = "leaf";
    else s = "internal node";
    cout << "node " << i << ": parent = " << par[i] << ", sibling = " << bro[i] << ", degree = " << chs[i] << ", depth = " << dep[i] << ", height = " << hei[i] << ", " << s << endl;
  }
}
