#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> cc(n);
  vector< vector<int> > C(n);
  vector<int> P(n, -1);
  for (int i = 0; i < n; i++){
    int u;
    cin >> u;
    int k;
    cin >> k;
    cc[u] = k;
    for (int j = 0; j < k; j++){
      int c;
      cin >> c;
      C[u].push_back(c);
      P[c] = u;
    }
  }
  int r;
  for (int i = 0; i < n; i++){
    if (P[i] == -1){
      r = i;
      break;
    }
  }
  vector<int> d(n, 0);
  queue<int> Q;
  Q.push(r);
  while (!Q.empty()){
    int v = Q.front();
    Q.pop();
    for (int i = 0; i < cc[v]; i++){
      d[C[v][i]] = d[v] + 1;
      Q.push(C[v][i]);
    }
  }
  for (int i = 0; i < n; i++){
    cout << "node " << i << ": parent = " << P[i] << ", depth = " << d[i];
    if (i == r){
      cout << ", root, [";
    } else if (cc[i] == 0){
      cout << ", leaf, [";
    } else {
      cout << ", internal node, [";
    }
    for (int j = 0; j < cc[i]; j++){
      cout << C[i][j];
      if (j < cc[i] - 1){
        cout << ", ";
      }
    }
    cout << "]" << endl;
  }
}
