#include<stdio.h>
#include<string.h>
#define MAX 30
/*------構造体定義------*/
typedef struct node{
 int id;
 int pareid;
 int sibid;
 int childnum;
 int depth;
 int height;
 char type[15];
 struct node *left;
 struct node *right;
}node;
/*------------------------*/


/*depth func----------------------------------------------------------*/
void depthcheck(node node[],int id){

if(node[id].left!=NULL)node[((node[id].left)->id)].depth=node[id].depth+1;
if(node[id].right!=NULL)node[((node[id].right)->id)].depth=node[id].depth+1;

if((node[id].left)->childnum!=0)depthcheck(node,(node[id].left)->id);
if((node[id].right)->childnum!=0)depthcheck(node,(node[id].right)->id);

}

/*------------------------------------------------------------*/




void heightcheck(node node[],int id){
 if(node[id].pareid==-1){return;}
 else if(node[node[id].pareid].height <= node[id].height+1){
    node[node[id].pareid].height=node[id].height+1;
    heightcheck(node,node[id].pareid);}


}





int main(){
int n,i,j;
int x,y,z;
node node[MAX];
int rootid;


scanf("%d",&n);/*データ数*/


/*-------------ノードの初期化-------------*/
for(i=0;i<n;i++){
node[i].id=i;
node[i].depth=0;
node[i].childnum=0;
node[i].pareid=-1;
node[i].sibid=-1;
node[i].height=0;
}
/*--------------------------------------*/










/*-----------------node情報の入力-------------------------*/
for(i=0;i<n;i++){

scanf("%d",&x);
node[x].id=x;

scanf("%d",&y);
if(y==-1){node[x].left==NULL;}
else{node[x].left=&node[y]; node[y].pareid=x;}

scanf("%d",&z);
if(z==-1){node[x].right==NULL;}
else{node[x].right=&node[z]; node[z].pareid=x;}


if((y!=-1)&&(z!=-1)){
 node[y].sibid=z;
 node[z].sibid=y;
 node[x].childnum=2;}
else if((y==-1)&&(z==-1)){
  node[x].childnum=0;
  strncpy(node[x].type,"leaf",4);node[x].type[4]='\0';
  node[x].height=0;}
else{node[x].childnum=1;}


}

/*------------------------------------------*/



/*----------root探索---------------*/
for(i=0;i<n;i++){
 if(node[i].pareid==-1){rootid=i;break;}
}
/*--------------------------------*/



depthcheck(node,rootid);






for(i=0;i<n;i++){
 
if(node[i].childnum==0){heightcheck(node,i);}


}







/*----------------nodeの種類の決定--------------------------*/
for(i=0;i<n;i++){
if(node[i].depth==0){strncpy(node[i].type,"root",4);node[i].type[4]='\0';}
else if(node[i].type[0]!='l'){strncpy(node[i].type,"internal node",13);node[i].type[13]='\0';}
}
/*------------------------------------------------------------*/






/*-----------------------表示----------------*/

for(i=0;i<n;i++){
printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n",i,node[i].pareid,node[i].sibid,node[i].childnum,node[i].depth,node[i].height,node[i].type);
}



return 0;
}

