#include<stdio.h>

#define MAX 100001
#define NIL -1

struct node{
  int parent;
  int left;
  int right;
};

struct node T[MAX];
int Dpt[MAX];

void setDepth(int, int);
void printch(int);

int main(){
  int n;
  int id, k;
  int ch, l;
  int root;
  int i, j;

  scanf("%d", &n);

  for(i=0; i<n; i++)
    T[i].parent = T[i].left = T[i].right = NIL;

  for(i=0; i<n; i++){
    scanf("%d%d", &id, &k);

    for(j=0; j<k; j++){
      scanf("%d", &ch);
      T[ch].parent = id;

      if(j==0)
	T[id].left = ch;

      else
	T[l].right = ch;

      l = ch;
    }

    if(T[id].parent == NIL)
      root = id;
  }

  setDepth(root, 0);

  for(i=0; i<n; i++){
    printf("node %d: parent = %d, depth = %d, ", i, T[i].parent, Dpt[i]);

    if(T[i].parent == NIL)
      printf("root, ");

    else if(T[i].left == NIL)
      printf("leaf, ");

    else
      printf("internal node, ");

    printf("[");
    printch(i);
    printf("]\n");
  }
  
  return 0;
}

void setDepth(int u, int par){
  Dpt[u] = par;
  if(T[u].right != NIL)
    setDepth(T[u].right, par);

  if(T[u].left != NIL)
    setDepth(T[u].left, par+1);
}

void printch(int u){
  int c;
  int num=0;

  c = T[u].left;

  while(c != NIL){
    if(num == 0)
      printf("%d",c);

    else
      printf(", %d",c);

    num++;
    c = T[c].right;
  }
}

