#include<stdio.h>
#define MAX 100005

int parent[MAX],left[MAX],right[MAX],n, D[MAX];

int getDepth(int u);
void setDepth(int u,int p);
void printChildren(int u);

int main(){
  int i,j,d,v,c,l,r,w,t;
  
  scanf("%d",&n);
  for(i=0;i<n; i++){
    parent[i] = -1;
    left[i] = -1;
    right[i] = -1;   
  }
  
  for(i = 0; i < n; i++){
    scanf("%d",&v);
    scanf("%d",&d);
    for(j = 0; j < d; j++){
      scanf("%d",&c);
      if(j == 0){
	left[v] = c;
      }
      else{
	right[l] = c;
      }
      l =c;
      parent[c] = v;
    }
  }

  for(w = 0; w< n; w++){
    if (parent[w] == -1 ) r = w;
  }
  setDepth(r,0);
  for(t = 0; t < n; t++)printChildren (t);
  return 0;
}

int getDepth(int u){
  int d = 0;
  while(parent[u] != -1){
    u = parent[u];
    d++;
  }
  return d;
}


void setDepth(int u, int p){
  D[u] = p;
  if(right[u] !=-1){
    setDepth(right[u],p);
  }
  if(left[u] != -1){
    setDepth(left[u],p+1);
  }
}
void printChildren(int u){
  int i,c;
  printf("node %d: ", u);
  printf("parent = %d, ", parent[u]);
  printf("depth = %d, ", getDepth(u));
  if(parent[u] == -1){
    printf("root, ");
  }
  else if (left[u] == -1){
    printf("left, ");
  }
  else{
    printf("internal node, ");
  }
  printf("[");
  for(i = 0, c = left[u]; c !=-1 ; i++,c = right[c]){
    if(i)printf(", ");
    printf("%d",c );
  }
  printf("]\n");
}

