module BinaryTree = struct
  let nil = -1

  type t = {
    mutable parent : int;
    mutable left : int;
    mutable right : int;
    mutable depth : int;
    mutable height : int;
  }

  let make () = {
    parent = nil;
    left = nil;
    right = nil;
    depth = nil;
    height = nil
  }
end

module T = BinaryTree

let _ =
  let n = read_int () in
  let t = Array.init n (fun _ -> T.make ()) in
  let rec read i =
    if i < n then begin
      let id, l, r = Scanf.scanf "%d %d %d\n" (fun id l r -> id, l, r) in
      t.(id).T.left <- l;
      t.(id).T.right <- r;
      if l <> T.nil then t.(l).T.parent <- id;
      if r <> T.nil then t.(r).T.parent <- id;
      read (i + 1)
    end
  in
  read 0;
  let rec search_root i =
    if i = n then T.nil
    else if t.(i).T.parent = T.nil then i
    else search_root (i + 1)
  in
  let root = search_root 0 in
  let rec set_depth i d =
    t.(i).T.depth <- d;
    if t.(i).T.left <> T.nil then set_depth t.(i).T.left (d + 1);
    if t.(i).T.right <> T.nil then set_depth t.(i).T.right (d + 1);
  in
  set_depth root 0;
  let rec set_height i =
    let hl = ref 0 in
    let hr = ref 0 in
    if t.(i).T.left <> T.nil then (set_height t.(i).T.left; hl := t.(t.(i).T.left).T.height + 1);
    if t.(i).T.right <> T.nil then (set_height t.(i).T.right; hr := t.(t.(i).T.right).T.height + 1);
    let h = max !hl !hr in
    t.(i).T.height <- h;
  in
  set_height root;
  let get_sibling i =
    if t.(i).T.parent = T.nil then T.nil
    else if t.(t.(i).T.parent).T.left <> i && t.(t.(i).T.parent).T.left <> T.nil then t.(t.(i).T.parent).T.left
    else if t.(t.(i).T.parent).T.right <> i && t.(t.(i).T.parent).T.right <> T.nil then t.(t.(i).T.parent).T.right
    else T.nil
  in
  let get_degree i =
    0 + (if t.(i).T.left <> T.nil then 1 else 0) + (if t.(i).T.right <> T.nil then 1 else 0)
  in
  let print i =
    print_string "node "; print_int i;
    print_string ": parent = "; print_int t.(i).T.parent;
    print_string ", sibling = "; print_int (get_sibling i);
    print_string ", degree = "; print_int (get_degree i);
    print_string ", depth = "; print_int t.(i).T.depth;
    print_string ", height = "; print_int t.(i).T.height;
    print_string (if t.(i).T.parent = T.nil then ", root" else if t.(i).T.left = T.nil && t.(i).T.right = T.nil then ", leaf" else ", internal node");
    print_newline ()
  in
  Array.iteri (fun i _ -> print i) t