#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
//#include<math.h>
#include<string.h>
//#include<time.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
typedef struct {
	int p,
		left,
		right;
}NODE;
NODE *node, tmp;

int main() {
	int n,i,id,k,j,c,r;
	int depth,t;
	fscanf(stdin, "%d", &n);
	node =(NODE*) malloc(sizeof(NODE)*n);
	for (i = 0; i < n; i++)
		node[i].p = node[i].left = node[i].right = -1;
	
	for (i = 0; i < n; i++) {
		fscanf(stdin, "%d%d", &id, &k);
		for (j = 0; j < k; j++) {
			fscanf(stdin, "%d", &c);
			if (j == 0)node[id].left = c;
			else node[r].right = c;
			node[c].p = id;
			r = c;
		}
	}
	for (i = 0; i < n; i++) {
		depth = 0;
		t = node[i].p;
		while (t != -1) {
			t = node[t].p;
			depth++;
		}
		if (node[i].p == -1)
			fprintf(stdout, "node %d: parent = %d, depth = %d, root, [", i, node[i].p, depth);
		else if( node[i].left==-1)
			fprintf(stdout,"node %d: parent = %d, depth = %d, leaf, [",i, node[i].p, depth);
		else 
			fprintf(stdout,"node %d: parent = %d, depth = %d, internal node, [",i, node[i].p, depth);
		t = node[i].left;
		if (t != -1) fprintf(stdout, "%d", t);
		while (t != -1) {
			t = node[t].right;
			if (t != -1)printf(", %d", t);
		}
		P(s, "]");
	}
	free(node);
	return 0;
}

