#include<stdio.h>
typedef struct{
  int parent,left,right;

} Bi;
Bi Node[10000];
#define B -1
int getSibling(int);
int setHeight(int);
int getDepth(int);

int main(){
  int n,i,j,v,l,r;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    Node[i].parent=B;
  }
  for(i=0;i<n;i++){
    scanf("%d%d%d",&Node[i].parent,&Node[i].left,&Node[i].right);
    v=Node[i].parent;
    l=Node[i].left;
    r=Node[i].right;
    if(l!=B)Node[l].parent=v;
    if(r!=B)Node[r].parent=v;

  }

  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, sibling = %d,",i,Node[i].parent,getSibling(i));
    int deg=0;
    if(Node[i].left!=B)deg++;
    if(Node[i].right!=B)deg++;
    printf("degree = %d,depth = %d, height = %d",deg,getDepth(i),setHeight(i));

}
  return 0;
}
int getSibling(i){
  if(Node[i].parent==B) return B;
  if(Node[Node[i].parent].left != i && Node[Node[i].parent].left != B)
  return Node[Node[i].parent].left;
  if(Node[Node[i].parent].right != i && Node[Node[i].parent].right != B)
  return Node[Node[i].parent].right;
  return B;
}
int getDepth(int i){
  int d=0;
  while (Node[i].parent!=B){
    i=Node[i].parent;
    d++;
  }
  return d;
}
int setHeight(int i){
  int h1=0,h2=0;
  if(Node[i].left!=B)h1=setHeight(Node[i].left)+1;
    if(Node[i].right!=B)h1=setHeight(Node[i].right)+1;
  if(h1>h2)return h1;
  else return h2;
}