#include <bits/stdc++.h>
using namespace std;

struct Node{
  int p, l, r;
};

Node T[100010];
int depth[100010];
int height[100010];

void rec( int s, int d = 0 ){
  depth[s] = d;
  if( T[s].r != -1 ) rec( T[s].r, d + 1 );
  if( T[s].l != -1 ) rec( T[s].l, d + 1 );
}

int rec2( int s ){
  int h1 = 0, h2 = 0;
  if( T[s].l != -1 ) h1 = rec2( T[s].l ) + 1;
  if( T[s].r != -1 ) h2 = rec2( T[s].r ) + 1;

  return height[s] = ( h1 > h2 ? h1 : h2 );
}

int degree( int v ){
  int res = 0;
  if( T[v].l != -1 ) res++;
  if( T[v].r != -1 ) res++;
  return res;
}

int sibling( int v ){
  if( T[v].p == -1 ) return -1;
  if( T[ T[v].p ].l != v ) return T[ T[v].p ].l;
  return T[ T[v].p ].r;
}

int main(){
  int N; cin >> N;
  for( int i = 0; i < 100010; i++ ) T[i].p = T[i].l = T[i].r = -1;

  for( int i = 0; i < N; i++ ){
    int id, left, right;
    cin >> id >> left >> right;

    T[id].l = left;
    T[id].r = right;
    T[left].p = id;
    T[right].p = id;
  }

  for( int i = 0; i < N; i++ ){
    if( T[i].p == -1 ){
      rec( i );
      rec2( i );
      break;
    }
  }
  
  for( int i = 0; i < N; i++ ){
    cout << "node " << i << ": " << "parent = " << T[i].p << ", "
	 << "sibling = " << sibling( i )
	 << ", degree = " << degree( i ) << ", "
	 << "depth = " << depth[i] << ", height = " << height[i] << ", ";
    
    if( T[i].p == -1 ) cout << "root";
    else if( T[i].l != -1 || T[i].r != -1 ) cout << "internal node";
    else cout << "leaf";
    cout << endl;
  }
  
}

