#include <stdio.h>
#include <stdlib.h>


typedef struct{
  int parent;
  int cnum;
  int child[2];
} Node;

void alr(int);
void lar(int);
void lra(int);

Node A[100000];

int main(){
  int n;
  int N;
  int num;
  int i,j;
  int root;
  
  
  
  scanf("%d",&n);
  for(i=0;i<n;i++) A[i].parent=-1;
  for(i=0;i<n;i++){
    scanf("%d",&num);
    A[num].cnum=0;
    for(j=0;j<2;j++){
      scanf("%d",&A[num].child[j]);
      if(A[num].child[j]!=-1){
        A[A[num].child[j]].parent=num;
        A[num].cnum++;
      }
    }
  }
  for(i=0;i<n;i++){
    if(A[i].parent==-1){
       root=i;
       break;
    }
  }
  printf("Preorder\n");
  alr(root);
  printf("\n");
  printf("Inorder\n");
  lar(root);
  printf("\n");
  printf("Postorder\n");
  lra(root);
  printf("\n");

  return 0;
}

void alr(int i){
  if(A[i].cnum==0){
     printf(" %d",i);
     return;
  }
  printf(" %d",i);
  if(A[i].child[0]!=-1) alr(A[i].child[0]);
  if(A[i].child[1]!=-1) alr(A[i].child[1]);
  return;
} 

void lar(int i){
  if(A[i].cnum==0){
     printf(" %d",i);
     return;
  }
  if(A[i].child[0]!=-1) lar(A[i].child[0]);
  printf(" %d",i);  
  if(A[i].child[1]!=-1) lar(A[i].child[1]);
  return;
}

void lra(int i){
  if(A[i].cnum==0){
     printf(" %d",i);
     return;
  }
  if(A[i].child[0]!=-1) lra(A[i].child[0]);
  if(A[i].child[1]!=-1) lra(A[i].child[1]);
  printf(" %d",i);
  return;
}

