#include <stdio.h>
#define MAX 10000000
#define noParent -1

struct  Node {int  parent,right,left; } ;
struct Node box[MAX];
int D[MAX];
int n;

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

int serchDepth(int u) {
	int d;
	d = 0;
	for(; box[u].parent != noParent ;d++){
		u = box[u].parent;
	}
		return d;
}

int main(){
  int i,j,a,b,c,l,r;

	scanf("%d", &n);
	for(i=0;i < n;i++){
		box[i].parent = box[i].left = box[i].right = noParent; 
	}
	
	for(i=0;i < n;i++){
		scanf("%d %d",&a,&b);
		for(j=0;j < b;j++){	
			scanf("%d",&c);
			if (j == 0) box[a].left = c;
			else box[l].right = c;
			l = c;
			box[c].parent = a;
		}
	}	
	r = 0;
	for (i = 0; i < n; i ++){
		D[i] = serchDepth(i);
		if(D[i] > r ) r = D[i];
		}
	
	for(i=0;i<n;i++) prints(i);
	
	return 0;
}
