#include <stdio.h>

#define MAX 100005
#define NIL -1

//pr = 節点の親,l = 節点の最も左の子,r = 節点のすぐ右隣の兄弟//
typedef struct {
  int pr,l,r;
}node;

node T[MAX];
int n,D[MAX];

void print(int u){
  int i,ch;
  printf("node %d: parent = %d, depth = %d, ",u,T[u].pr,D[u]);
  if(T[u].pr == NIL) printf("root, ");
  else if(T[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");

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

void getdepth(int u,int p){
  D[u] = p;
  if(T[u].r != NIL) getdepth(T[u].r,p);
  if(T[u].l != NIL) getdepth(T[u].l,p+1);
}

int main(){
  int i,j,deg,id,ch,l,r;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].pr = T[i].l = T[i].r = NIL;

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

  getdepth(r,0);

  for(i=0;i<n;i++) print(i);

  return 0;
}
      

