#include<stdio.h>
#define MAX 100005
#define NIL -1

typedef struct{
  int parent, left, right;
}Node;

Node Tree[MAX];
int degree[MAX];
int n;

void walkP(int);
void walkI(int);
void walkPo(int);

int main(void){
  int i;
  int vertex;
  int child[2];


  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    Tree[i].parent = NIL;
    Tree[i].left = NIL;
    Tree[i].right = NIL;
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d %d", &vertex, &child[0], &child[1]);

    //子どもがいない場合はdegreeは0である。
    if(child[0] == NIL && child[1] == NIL)
      degree[vertex] = 0;

    //子どもがどちらかにいればdegreeは1である。
    else if(child[0] == NIL && child[1] != NIL){
      degree[vertex] = 1;
      Tree[child[1]].parent = vertex;
      Tree[vertex].right = child[1];
    }
    
    else if(child[0] != NIL && child[1] == NIL){
      degree[vertex] = 1;
      Tree[child[0]].parent = vertex;
      Tree[vertex].left = child[0];
    }


    //子どもが両方存在するという事はdegreeは2という事
    else{
      degree[vertex] = 2;
      Tree[child[0]].parent = vertex;
      Tree[child[1]].parent = vertex;
      
      Tree[vertex].left = child[0];
      Tree[vertex].right = child[1];
    }
  }

  printf("Preorder\n");
  for(i = 0; i < n; i++){
    if(Tree[i].parent == NIL)
      walkP(i);
  }
  printf("\n");


  printf("Inorder\n");
  for(i = 0; i < n; i++){
    if(Tree[i].parent == NIL)
      walkI(i);
  }
  printf("\n");

  printf("Postorder\n");
  for(i = 0; i < n; i++){
    if(Tree[i].parent == NIL)
      walkPo(i);
  }
  printf("\n");

  
  return 0;
}

void walkP(int v){
  int left = Tree[v].left;
  int right = Tree[v].right;
  
  printf(" %d",v);
  
  if(left != NIL )
    walkP(left);

  if(right != NIL)
  walkP(right);

}

void walkI(int v){
  int left = Tree[v].left;
  int right = Tree[v].right;
  
  if(left != NIL)
    walkI(left);
  
  printf(" %d",v);
  
  if(right != NIL)
    walkI(right);
}

void walkPo(int v){
  if(v != NIL)
    walkPo(Tree[v].left);

  if(v != NIL){
    walkPo(Tree[v].right);
    printf(" %d",v);
  }
}