#include <iostream>
using namespace std;

struct Node {
  int p, l, r;
};

struct Node T[10000];
int n;

//先行順巡回
void preParse(int u) {
  if ( u == -1 ) return;
  cout << " " << u;
  preParse(T[u].l);
  preParse(T[u].r);  
}

//中間順巡回
void inParse(int u) {
  if ( u == -1 ) return;
  inParse(T[u].l);
  cout << " " << u;
  inParse(T[u].r);
}

//後行順巡回数
void postParse(int u) {
  if ( u == -1 ) return;
  postParse(T[u].l);
  postParse(T[u].r);
  cout << " " << u;
}

int main() {
  int v, l, r, root;
  
  cin >> n;
  //初期化
  for ( int i = 0; i < n; i++ ) {
    T[i].p = -1;
  }
  
  //入力
  for ( int i = 0; i < n; i++ ) {
    cin >> v >> l >> r;
    T[v].l = l;
    T[v].r = r;
    if ( l != -1 ) T[l].p = v;
    if ( r != -1 ) T[r].p = v;    
  }

  for ( int i = 0; i < n; i++ ) if ( T[i].p == -1 ) root = i;
  
  cout << "Preorder" << endl;
  preParse(root);
  cout << endl;
  cout << "Inorder" << endl;
  inParse(root);
  cout << endl;
  cout << "Postorder" << endl;
  postParse(root);
  cout << endl;

  return 0;
}