#include <stdio.h>
#define MAX 100005
#define NIL -1

struct Node {
    int parent, left, right;
};

struct Node Tree[MAX];
int n, Depth[MAX];

void print (int u) {
    int i, c;

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


void setDepth
 (int u, int p) {
    Depth[u] = p;
    if ( Tree[u].right != NIL) setDepth(Tree[u].right, p); //右の兄弟に同じ深さを設定
    if ( Tree[u].left != NIL) setDepth(Tree[u].left, p+1); //最も左の子に自分の深さ+1を設定
}

int main () {
    int i, j, id, id_k, c, l, r;
    scanf("%d",&n);
    for ( i = 0; i < n; i++) Tree[i].parent = Tree[i].left = Tree[i].right = NIL;

    for ( i = 0; i < n; i++) {
        scanf("%d%d",&id,&id_k);
        for ( j = 0; j < id_k; j++) {
            scanf("%d",&c);
            if ( j == 0) Tree[id].left = c;
            else Tree[l].right = c;
            l = c;
            Tree[c].parent = id;
        }
    }

    for ( i = 0; i < n; i++) {
        if (Tree[i].parent == NIL) r = i;
    }

    setDepth(r, 0);

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

    return 0;
}
