#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
const int nmax=100;
vector<int> dep(nmax),par(nmax),high(nmax);
vector<int> des[nmax];

void dep_dfs(int id){
    for(int i=0;i<des[id].size();i++){
        dep[des[id][i]]=dep[id]+1;
        dep_dfs(des[id][i]);
    }
}
void hi_dfs(int id){
    if(par[id]!=-1){
        high[par[id]]=max(high[par[id]],high[id]+1);
        hi_dfs(par[id]);
    }
}
int bro(int id){
    int p=par[id];
    if(p==-1) return -1;
    for(int i=0;i<des[p].size();i++)if(des[p][i]!=id) return des[p][i];
    return -1;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  for(int i=0;i<n;i++){
      par[i]=-1;
      high[i]=0;
      dep[i]=0;
  }
  for(int i=0;i<n;i++){
      int id,left,right;cin>>id>>left>>right;
      if(left!=-1){
          des[id].push_back(left);
          par[left]=id;
      }
      if(right!=-1){
          des[id].push_back(right);
          par[right]=id;
      }
  }
  for(int i=0;i<n;i++){
      if(par[i]==-1) dep_dfs(i);
      if(!des[i].size())hi_dfs(i);
  }
  for(int i=0;i<n;i++){
      string type;
      if(par[i]==-1) type="root";
      else if(!des[i].size()) type="leaf";
      else type="internal node";
      cout<<"node"<<" "<<i<<": parent = "<<par[i]<<", sibling = "<<bro(i)<<", degree = "<<des[i].size()<<", depth = "<<dep[i]<<", height = "<<high[i]<<", "<<type<<endl;
  }
}