#include <stdio.h>
#define MAX 100000+45
#define NIL -1

typedef struct node_ {
    int parent;
    int left;
    int right;
    
} Node;

Node T[MAX];

int arg(int v) {
    int f = 0;
    for (f=0;T[v].parent != NIL;f++) {
        v = T[v].parent;     
    }
    return f;
}




void print(int u) {
    int i;
    int mid;
    int c = T[u].left;
	printf("node %d: ", u);
    printf("parent = %d, ", T[u].parent);
    printf("depth = %d, ", arg(u));
    if (T[u].parent == NIL) {
        printf("root, ");
    } else if (T[u].left == NIL) {
        printf("leaf, ");
    } else {
        printf("internal node, ");
    }
    printf("[");
    for (i = 0; c != NIL; i++) {
        if (i) printf(", ");printf("%d", c);
        c = T[c].right;
    }
    printf("]\n");
}

int main(void) {
    int i, j;
    int n;
	int c; 
	int key, k, left;
    scanf("%d", &n);
    i = 0;
	while (i < n) {
        T[i].parent = NIL;
        T[i].left = NIL;
        T[i].right = NIL;
          i++;
    }
    for (i = 0; i < n; i++) {
        scanf("%d %d", &key, &k);
        for (j = 0; j < k; j++) {
            
            scanf("%d", &c);
            if (j == 0) T[key].left = c;
            else T[left].right = c;
            left = c;
            T[c].parent = key;
        }
    }

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

    return 0;
}
