#include<stdio.h>
#define MAX 100000

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

Node tree[MAX];
int depth[MAX],child[MAX];
int n;

int getdepth(int x){
  int d=0;

  while(tree[x].p>=0){
    x=tree[x].p;
    d++;
  }
  return d;
}

void print(int x){
  int i,cnt=0;

  printf("node %d: parent = %d, depth = %d, ",x,tree[x].p,depth[x]);

  if(tree[x].p==-1)
    printf("root, [");
  else if(tree[x].l==-1)
    printf("leaf, [");
  else
    printf("internal node, [");

  x=tree[x].l;
  while(x!=-1){
    if(cnt==0)
      printf("%d",x);
    else
      printf(", %d",x);

    x=tree[x].r;
    cnt++;
  }
  printf("]\n");
}

int main(){
  int i,j;
  int k,x;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    tree[i].p=-1;
    tree[i].l=-1;
    tree[i].r=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&x,&k);
    for(j=0;j<k;j++){
      scanf("%d",&child[j]);
      tree[child[j]].p=x;

      if(j==0)
        tree[x].l=child[0];
      else
        tree[child[j-1]].r=child[j];
    }
  }

  for(i=0;i<n;i++)
    depth[i] = getdepth(i);

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

  return 0;
}