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

typedef struct{
	int p, lc, rs;
}node;

node T[MAX];
int i,j,n;


int main(void) {
	int id, k, c, d=0, count, temp;
	
	scanf("%d", &n);
	//initialize
	for (i=0; i<n; i++){
		T[i].p = T[i].lc = T[i].rs = NIL;
	}
	
	for(i=0; i<n; i++){
		scanf("%d %d", &id, &k);
	
		for(j=0; j<k; j++){
			scanf("%d", &c);
		
			if(j==0)
				T[id].lc = c;
			else 
				T[temp].rs = c;
			temp = c;
			T[c].p = id;
		}

	}
	
	for(i=0; i<n; i++){
		printf("node %d: parent = %d, ", i, T[i].p);
		count = i;
		while(T[count].p != NIL){
			d++;
			count = T[count].p;
		}
		printf("depth = %d, ", d);
		d=0;
		if (T[i].p == NIL)
			printf("root, ");
		else if (T[i].lc == NIL)
			printf("leaf, ");
		else printf("internal node, ");
		printf("[");
		c = T[i].lc;
		if (c == NIL)
			printf("]\n");
		else{
			count = 0;
			while(c != NIL) {
				if (count == 0)
					printf("%d", c);
				else 
					printf(", %d", c);
				c = T[c].rs;
				count++;
			}
			printf("]\n");
		}	
	}
	
	return 0;
}

