module DoublyChainedTree = struct
  let nil = -1

  type t = {
    mutable parent : int;
    mutable child : int;
    mutable bro : int;
    mutable depth : int;
  }

  let make () = { parent = nil; child = nil; bro = nil; depth = nil }
end

module T = DoublyChainedTree

let () =
  let n = read_int () in
  let t = Array.init n (fun _ -> T.make ()) in
  for _ = 0 to n - 1 do
    Scanf.scanf "%d %d " (fun id k ->
      let left_child = ref 0 in
      for j = 0 to k - 1 do
        Scanf.scanf "%d " (fun c ->
          t.(c).T.parent <- id;
          if j = 0 then t.(id).T.child <- c else t.(!left_child).T.bro <- c;
          left_child := c)
      done)
  done;
  let root = ref 0 in
  for i = 0 to n - 1 do
    if t.(i).T.parent = T.nil then root := i;
  done;
  let rec set_depth i p =
    t.(i).T.depth <- p;
    if t.(i).T.bro <> T.nil then set_depth t.(i).T.bro p;
    if t.(i).T.child <> T.nil then set_depth t.(i).T.child (p + 1);
  in
  set_depth !root 0;
  let print_tree i =
    Printf.printf "node %d : parent = %d, depth = %d, " i t.(i).T.parent t.(i).T.depth;
    print_string (if t.(i).T.parent = T.nil then "root, " else if t.(i).T.child = T.nil then "leaf, " else "internal node, ");
    print_string "[";
    let c = ref t.(i).T.child in
    while !c <> T.nil do
      if !c <> t.(i).T.child then print_string ", ";
      print_int !c;
      c := t.(!c).T.bro;
    done;
    print_endline "]"
  in
  for i = 0 to n - 1 do
    print_tree i
  done