#include <stdio.h>
#define MAX 100005
#define NIL -1

typedef struct node{
  int p; 
  int l;
  int r;
}Node;

void print(int u);
int rec(int u, int p);

Node T[MAX];
int n = 0, D[MAX];

int main(){
  int i = 0, j = 0;
  int d = 0, v = 0, c = 0, l = 0, r = 0;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    T[i].p = T[i].l = T[i].r = NIL;
  }

  for(i = 0; i < n; i++){
    scanf("%d%d",&v,&d);
    for(j = 0; j < d; j++){
      scanf("%d",&c);
      if(j == 0)T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  for(i = 0; i < n; i++){
    if(T[i].p == NIL)r = i;
  }

  rec(r, 0);

  for(i = 0; i < n; i++){
    print(i);
  }
  
  return 0;
}

void print(int u){
  int i = 0, c = 0;
  
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("depth = %d, ",D[u]);

  if(T[u].p == NIL)printf("root, [");
  else if(T[u].l == NIL)printf("leaf, [");
  else printf("internal node, [");

  c = T[u].l;
  for(i = 0; c != NIL; i++){
    if(i)printf(", ");
    printf("%d",c);
    c = T[c].r;
  }

  printf("]\n");

}

int rec(int u, int p){
  D[u] = p;
  if(T[u].r != NIL)rec(T[u].r, p);
  if(T[u].l != NIL)rec(T[u].l, p+1);
}
/*Input
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d%d",&id,&k);
    T[i].sibling = k;
    if(k == 0){
      T[id].left[0] = -1;  子がいなければleftに-1  
    }
    T[i].parent = -2; もしrootだった時に-2のままのものを探す
    for(j = 0; j < k; j++){
      scanf("%d",&T[id].left[j]);
      T[T[id].left[j]].parent = id;
    }
  }

  Output
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, ",i,T[i].parent);
    
    depth = 0;
    j = i;
    while(T[j].parent != -1){
      j = T[j].parent;
      depth++;
    }
    printf("depth = %d, ",depth);
    
    if(T[i].parent == -2){
      printf("root, [");
    }
    else if(T[i].left[0] == -1)printf("leaf, []\n");
    else printf("internal node, [");

    if(T[i].left[0] != -1){
      for(l = 0; l < T[i].sibling; l++){
	if(l == T[i].sibling -1){
	  printf("%d]\n",T[i].left[l]);
	}
	else printf("%d, ",T[i].left[l]);
      }
    }
  }
*/

