#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
using ULL = unsigned long long int;
using D = double;
using LD = long double;
#define int LL
// #define double LD
template <typename T> using V = std::vector<T>;
using VI = V<int>;
using VS = V<std::string>;
using VVI = V<V<int>>;
using VVVI = V<V<V<int>>>;
using VD = V<double>;
using VVD = V<V<double>>;
#define VIIN(A) VI A(read()); for(auto&& e: A) { e = read(); }
#define VSIN(A) VS A(read()); for(auto&& e: A) { e = readS(); }
#define PB push_back
#define RSV reserve
#define EB emplace_back
#define ALL(A) std::begin(A), std::end(A)
#define SUM(A) std::accumulate(ALL(A), int(0))
#define SUMD(A) std::accumulate(ALL(A), double(0))
#define AVE(A) SUM(A)/(A).size()
#define AVED(A) SUMD(A)/(A).size()
#define MAX(A) *std::max_element(ALL(A))
#define MIN(A) *std::min_element(ALL(A))
#define SORT(A) std::sort(ALL(A))
#define SSORT(A) std::stable_sort(ALL(A))
#define SORTG(A) std::sort(ALL(A), std::greater<>())
#define REV(A) std::reverse(ALL(A))
#define UNQ(A) SORT(A); (A).erase(std::unique(ALL(A)), std::end(A))
#define UNQG(A) SORTG(A); (A).erase(std::unique(ALL(A)), std::end(A))
using CD = std::complex<double>;
template <typename T1, typename T2> using P = std::pair<T1, T2>;
template <typename T> using PI = P<int, T>;
using PII = PI<int>;
using PIS = PI<std::string>;
using PSI = P<std::string, int>;
#define MP std::make_pair
#define F first
#define S second
#define FOR(var,a,b)  for (auto var=(a); var<(b); ++var)
#define RFOR(var,a,b)  for (auto var=(b)-1; var!=(a); --var)
#define REP(var,n)  for (decltype(n) var=0; var<(n); ++var)
#define RREP(var,n)  for (auto var = n-1; var!=static_cast<decltype(var)>(-1); --var)
#define YES(A) ((A) ? "yes" : "no")
constexpr int kMOD = 1e9+7;
const double kPI = std::acos(-1);
struct Read {
	auto operator()(void) { int d; std::cin >> d; return d; }
}read;
struct ReadReal {
	auto operator()(void) { double d; std::cin >> d; return d; }
}readR;
struct ReadString {
	auto operator()(void) { std::string s; std::cin >> s; return s; }
}readS;
struct ReadEof {
	auto operator()(void) { return std::cin.eof(); }
}readEof;
struct Print {
	void operator()(void) { std::cout << " "; }
	void operator()(double lf) {
		std::cout << std::fixed << std::setprecision(8) << lf;
	}
	template <typename T> void operator()(T t) {
		std::cout << t;
	}
	template <typename T>
	void operator()(const std::complex<T> &c, const std::string &sep = " ") {
		Print()(c.real());
		Print()(sep);
		Print()(c.imag());
	}
	template <typename T1, typename T2>
	void operator()(const std::pair<T1, T2> &pair, const std::string &sep = " ") {
		Print()(pair.first);
		Print()(sep);
		Print()(pair.second);
	}
	template <typename T>
	void operator()(T begin, T end, const std::string &sep = " ") {
		if (begin == end) return;
		Print()(*begin);
		for(auto it = ++begin;  it != end; ++it) {
			Print()(sep);
			Print()(*it);
		}
	}
	template <typename T>
	void operator()(const std::vector<T> &v, const std::string &sep = " ") {
		Print()(std::begin(v), std::end(v), sep);
	}
	template <typename T>
	void operator()(std::initializer_list<T> list, const std::string &sep = " ") {
		Print()(std::begin(list), std::end(list), sep);
	}
}print;
struct Println {
	void operator()(void) { std::cout << "\n"; }
	void operator()(double lf) {
		Print()(lf);
		Println()();
	}
	template <typename T> void operator()(T t) {
		Print()(t);
		Println()();
	}
	template <typename T>
	void operator()(const std::complex<T> &c, const std::string &sep = " ") {
		Print()(c, sep);
		Println()();
	}
	template <typename T1, typename T2>
	void operator()(const std::pair<T1, T2> &pair, const std::string &sep = " ") {
		Print()(pair, sep);
		Println()();
	}
	template <typename T>
	void operator()(T begin, T end, const std::string &sep = " ") {
		Print()(begin, end, sep);
		Println()();
		return;
	}
	template <typename T>
	void operator()(const std::vector<T> &v, const std::string &sep = " ") {
		Print()(std::begin(v), std::end(v), sep);
		Println()();
	}
	template <typename T>
	void operator()(std::initializer_list<T> list, const std::string &sep = " ") {
		Print()(std::begin(list), std::end(list), sep);
		Println()();
	}
}println;
inline void Main(void);
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	Main();
	std::cout << std::flush;
	return 0;
}

constexpr int kEmpty = -1;
struct Node {
	int parent;
	int left;	// 子
	int right;	// 兄弟
};
void SetDepth(const V<Node> &tree, VI *depth, int target, int step) {
	auto &d = *depth;
	if (target == kEmpty)
		return;
	d[target] = step;
	SetDepth(tree, &d, tree[target].left, step + 1);
	SetDepth(tree, &d, tree[target].right, step + 1);
}
int SetHeight(const V<Node> &tree, VI *height, int target) {
	auto &h = *height;
	if (target == kEmpty)
		return -1;
	auto l_height =  SetHeight(tree, &h, tree[target].left);
	auto r_height =  SetHeight(tree, &h, tree[target].right);
	return h[target] = max(r_height, l_height) + 1;
}
int SearchRoot(const V<Node> &tree) {
	REP(i, tree.size()) {
		if (tree[i].parent == kEmpty) {
			return i;
		}
	}
	return 0;
}
int SearchDegree(const V<Node> &tree, int target) {
	int count = 0;
	if (tree[target].left != kEmpty)
		count++;
	if (tree[target].right != kEmpty)
		count++;
	return count;
}
int SearchSibling(const V<Node> &tree, int target) {
	auto parent = tree[target].parent;
	if (parent == kEmpty)
		return kEmpty;
	auto left = tree[parent].left;
	if (left == target)
		return tree[parent].right;
	return left;
}
string NodeLocate(const V<Node> &tree, int target) {
	if (tree[target].parent == kEmpty) {
		return "root";
	} else if (tree[target].left == kEmpty && tree[target].right == kEmpty) {
		return "leaf";
	}
	return "internal node";
}
inline void Main(void) {
	// 入力
	V<Node> tree(read(), {kEmpty, kEmpty, kEmpty});
	REP(i, tree.size()) {
		auto id = read();
		auto left = tree[id].left = read();
		if (left != kEmpty)
			tree[left].parent = id;
		auto right = tree[id].right = read();
		if (right != kEmpty)
			tree[right].parent = id;
	}
	// 深さ計算
	VI depth(tree.size());
	auto root = SearchRoot(tree);
	SetDepth(tree, &depth, root, 0);
	VI height(tree.size());
	SetHeight(tree, &height, root);
	// 出力
	REP(i, tree.size()) {
		cout << "node " << i << ": ";
		cout << "parent = " << tree[i].parent << ", ";
		cout << "sibling = " << SearchSibling(tree, i) << ", ";
		cout << "degree = " << SearchDegree(tree, i) << ", ";
		cout << "depth = " << depth[i] << ", ";
		cout << "height = " << height[i] << ", ";
		cout << NodeLocate(tree, i) << "\n";
	}
}



Measured memory_bytes: 3232