import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	static class Node {
		int id;
		int parentId;
		int depth;
		int[] children;
		public Node(int id, int parentId) {
			this.id = id;
			this.parentId = parentId;
			this.children = null;
			this.depth = 0;
		}
		public void setChildlen(int[] childlen) {
			this.children = childlen;
		}
		public void setParentId(int parentId) {
			this.parentId = parentId;
		}
		public void setDepth(int depth) {
			this.depth = depth;
		}
		private String getType() {
			if (depth == 0) {
				return "root";
			}
			if (children == null || children.length == 0) {
				return "leaf";
			}
			return "internal node";
		}		
		public String toString() {
			StringBuilder sb = new StringBuilder();
			sb.append("node " + id + ": ");
			sb.append("parent = " + parentId + ", ");
			sb.append("depth = " + depth + ", ");
			sb.append(getType() + ", ");
			sb.append(Arrays.toString(children));
			return sb.toString();
		}
	}
		
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		Node[] nodes = new Node[n];

		for (int i = 0; i < n; i++) {
			
			StringTokenizer st = new StringTokenizer(reader.readLine());
			
			int id = Integer.parseInt(st.nextToken());
			if (nodes[id] == null) {
				nodes[id] = new Node(id, -1);
			}
			
			int m = Integer.parseInt(st.nextToken());
			int[] children = new int[m];
			for (int j = 0; j < m; j++) {
				int childId = Integer.parseInt(st.nextToken());
				children[j] = childId;
				if (nodes[childId] == null) {
					nodes[childId] = new Node(childId, id);
				} else {
					nodes[childId].setParentId(id);
				}
				nodes[childId].setDepth(nodes[id].depth + 1);
			}
			nodes[id].setChildlen(children);
		}
		
		for (Node node : nodes) {
			System.out.println(node);
		}
	}
}



### FIXED CODE ###

class Node:
	def __init__(self, id):
		self.id = id
		self.parent_id = -1
		self.depth = -1
		self.children = None
	def get_type(self):
		if self.parent_id == -1:
			return 'root'
		elif self.children == None or len(self.children) == 0:
			return 'leaf'
		return 'internal node'
	def __str__(self):
		strNode = 'node ' + str(self.id) + ': '
		strNode += 'parent = ' + str(self.parent_id) + ', '
		strNode += 'depth = ' + str(self.depth) + ', '
		strNode += self.get_type() + ', ['
		if len(self.children) > 0:
			strNode += str(self.children[0])
			for i in range(1, len(self.children)):
				strNode +=  ', ' + str(self.children[i])
		strNode += ']'
		return strNode

def calc_depth(nodes):
	stack = []
	for i in range(len(nodes)):
		if nodes[i].parent_id == -1:
			nodes[i].depth = 0
			stack.append(nodes[i].id)
			break
	while len(stack) != 0:
		node = nodes[stack.pop()]
		for i in range(len(node.children)):
			child_id = node.children[i]
			nodes[child_id].depth = node.depth + 1
			stack.append(child_id)

n = int(input())
nodes = [Node(i) for i in range(n)]
for i in range(n):
	a = list(map(int, input().split()))
	id = a[0]
	m = a[1]
	children = [0] * m
	for j in range(m):
		child_id = a[2 + j]
		child = nodes[child_id]
		child.parent_id = id
		children[j] = child_id
	nodes[id].children = children

calc_depth(nodes)

for i in range(n):
	print(nodes[i])