#include <stdio.h>
int N;
int parent[100001];
char isLeaf[100001];

int calcDepth(int a) {
  if(parent[a] == -1) return 0;
  return calcDepth(parent[a]) + 1;
}

int main() {
  int i;
  int b;
  int id, key;
  scanf("%d", &N);
  
  for(i = 0; i < N; ++i) {

    parent[i] = -1;
    isLeaf[i] = 1;
  }
  
  for(i = 0; i < N; ++i) {

    scanf("%d %d", &id, &key);

    while(key--) {
      
      scanf("%d", &b);
      parent[b] = id;
      isLeaf[id] = 0;
    }
  }
  
  for(i = 0; i < N; ++i) {
    int depth = calcDepth(i);

    printf("node %d: parent = %d, depth = %d, ", i, parent[i], depth);
    if(isLeaf[i]) {
      printf("leaf\n");
    } else if(depth == 0) {
      printf("root\n");
    } else {
      printf("internal node\n");

    }
  }
  return 0;
}

