#include <stdio.h>
#include <stdlib.h>

typedef struct{
	int parent; //parent
	int left; //chlid of left
	int right; //sibling of right
}Node;

int main(){
	int n, k, id, ch, r, dep, p, i, j;
	Node *T;

	scanf("%d", &n);

	T = malloc(sizeof(Node)*n);

	//initialize
	for(i = 0; i < n; i++){
		T[i].parent = -1;
		T[i].left = -1;
		T[i].right = -1;
	}

	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; //insert left child
			else if(j > 0) T[r].right = ch; //insert sibling

			r = ch;
		}
	}

	for(j = 0; j < n; j++){
		dep = 0;
		p = T[j].parent;

		//parent of root = -1
		while(p != -1){
			p = T[p].parent;
			dep++;
		}
		if(dep == 0){
			printf("node %d: parent = -1, depth = 0, root, [", j);
		}
		else if(T[j].left == -1){
			printf("node %d: parent = %d, depth = %d, leaf, [", j, T[j].parent, dep);
		}
		else{
			printf("node %d: parent = %d, depth = %d, internal node, [", j, T[j].parent, dep);
		}

		p = T[j].left;
		if(p != -1) printf("%d", p);

		while(p != -1){
			p = T[p].right;
			if(p != -1) printf(", %d", p);
		}
		printf("]\n");
	}

	return 0;
}