#include <stdio.h>
#include <string.h>

typedef struct {
  int par, l_ch, r_sib, depth;
} node;

#define MAX_N 100000

node T[MAX_N];
int n;

void dfs(int u, int d) {
  T[u].depth = d;
  if(T[u].r_sib != -1) dfs(T[u].r_sib, d);
  if(T[u].l_ch != -1) dfs(T[u].l_ch, d+1);
}

int main() {
  int i, j;
  {
    for(i = 0; i < MAX_N; i++) {
      T[i] = (node){-1, -1, -1, -1};
    }
  }
  {
    scanf("%d", &n);
    for(i = 0; i < n; i++) {
      int id, k, p;
      scanf("%d %d", &id, &k);
      p = -1;
      for(j = 0; j < k; j++) {
	int c;
	scanf("%d", &c);
	if(T[id].l_ch == -1) T[id].l_ch = c;
	else T[p].r_sib = c;
	p = c;
	T[c].par = id;
      }
    }
  }
  {
    int root = -1;
    for(i = 0; i < n; i++) {
      if(T[i].par == -1) root = i;
    }

    dfs(root, 0);

    for(i = 0; i < n; i++) {
      char type[256];
      if(T[i].par == -1) strcpy(type, "root");
      else if(T[i].l_ch == -1) strcpy(type, "leaf");
      else strcpy(type, "internal node");
      printf("node %d: parent = %d, depth = %d, %s, ", i, T[i].par, T[i].depth, type);
      printf("[");
      if(T[i].l_ch != -1) {
	int p = T[i].l_ch;
	printf("%d", T[i].l_ch);
	while(T[p].r_sib != -1) {
	  printf(", %d", T[p].r_sib);
	  p = T[p].r_sib;
	}
      }
      puts("]");
    }
  }


  return 0;
}