#include <bits/stdc++.h>
using namespace std;

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

Node T[100010];

void Preorder( int s ){
  if( s == -1 ) return;

  cout << " " << s;
  Preorder( T[s].l );
  Preorder( T[s].r );
}

void Inorder( int s ){
  if( s == -1 ) return;
  
  Inorder( T[s].l );
  cout << " " << s;
  Inorder( T[s].r );
}

void Postorder( int s ){
  if( s == -1 ) return;
  
  Postorder( T[s].l );
  Postorder( T[s].r );
  cout << " " << s;
}

int main(){
  int N; cin >> N;
  for( int i = 0; i < 100010; i++ ) T[i].p = T[i].l = T[i].r = -1;

  for( int i = 0; i < N; i++ ){
    int id, left, right;
    cin >> id >> left >> right;

    T[id].l = left;
    T[id].r = right;
    T[left].p = id;
    T[right].p = id;
  }

  for( int i = 0; i < N; i++ ){
    if( T[i].p == -1 ){
      cout << "Preorder" << endl;
      Preorder( i );
      cout << endl;

      cout << "Inorder" << endl;
      Inorder( i );
      cout << endl;

      cout << "Postorder" << endl;
      Postorder( i );
      cout << endl;

      break;
    }
  }
  
}

