#include<stdio.h>
#define N 25

int i;
 
typedef struct{
  int parent;
  int left;
  int right;
}tree;
 
int pre(int), in(int), post(int);
tree T[N];

int main(){
  int n;
  int id, left, right;
 
  scanf("%d\n",&n);
  for(i = 0; i < n; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
  }
 
  for(i = 0 ; i < n ; i++){
    scanf("%d %d %d", &id, &left, &right);
    T[id].left = left;
    T[left].parent = id;
    T[id].right = right;
    T[right].parent = id;
  }
 
  printf("Preorder\n");
  for(i = 0 ; i < n ; i++){
    if(T[i].parent == -1) pre(i);
  }
  printf("\n");
 
  printf("Inorder\n");
  for(i = 0 ; i < n ; i++){
    if(T[i].parent == -1) in(i);
  }
  printf("\n");
 
  printf("Postorder\n");
  for(i = 0 ; i < n ; i++){
    if(T[i].parent == -1) post(i);
  }
  printf("\n");
     
  return 0;
}

int pre(int j){
  if(j == -1) return;
  printf(" %d", j);
  pre(T[j].left);
  pre(T[j].right);
}
 
int in(int j){
  if(j == -1) return;
  in(T[j].left);
  printf(" %d", j);
  in(T[j].right);
}
 
int post(int j){
  if(j == -1) return;
  post(T[j].left);
  post(T[j].right);
  printf(" %d", j);
}