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

#define INF -1

struct Node{
  int parent,left,right;
};

int H[30];
Node T[30];
int D[30];

void setdeep(int u,int d);
int setHeight(int u);

int main(){
  int n,id,l,r,root;
  cin>>n;
  
  //初期化
  for(int i=0;i<n;i++){
    T[i].parent=INF;
  }
 
  //入力
  for(int i=0;i<n;i++){
    cin>>id>>l>>r;
    T[id].left=l;
    T[id].right=r;
    if(l!=INF)T[l].parent=id;
    if(r!=INF)T[r].parent=id;
  }
  for(int i=0;i<n;i++){
    if(T[i].parent==INF)root=i;
  }

  //高さ求める
  setHeight(root);
  
  //深さを求める
  setdeep(root,0);
  
  //出力
  for(int i=0;i<n;i++){
    cout<<"node "<<i<<": ";
    cout<<"parent = "<<T[i].parent<<", ";
    cout<<"sibling = ";
    if(i==root)cout<<"-1";
    else if(T[T[i].parent].left==i)cout<<T[T[i].parent].right;
    else if(T[T[i].parent].right==i)cout<<T[T[i].parent].left;
    cout<<", ";
    int cnt=0;
    if(T[i].left!=INF)cnt++;
    if(T[i].right!=INF)cnt++;
    cout<<"degree = "<<cnt<<", ";
    cout<<"depth = "<<D[i]<<", ";
    cout<<"height = "<<H[i]<<", ";
    if(i==root)cout<<"root"<<endl;
    else if(T[i].left==INF && T[i].right==INF)cout<<"leaf"<<endl;
    else cout<<"internal node"<<endl;
  }
}

  


int setHeight(int u){
  int hl=0,hr=0;
  if(T[u].left!=INF){
    hl=setHeight(T[u].left)+1;
  }
  if(T[u].right!=INF){
    hr=setHeight(T[u].right)+1;
  }
  return H[u]=max(hl,hr);
}
  
void setdeep(int u,int d){
  D[u]=d;
  if(T[u].left!=INF){
    setdeep(T[u].left,d+1);
  }
  if(T[u].right!=INF){
    setdeep(T[u].right,d+1);
  }
  return;
}