#include<stdio.h>
#define N 25
#define NIL -1

struct Node {
  int parent;
  int left;
  int right;
};
struct Node T[N];

void preorder(int nodeid) {
  
  printf(" %d",nodeid);
  if(T[nodeid].left != NIL)
    preorder(T[nodeid].left);  
  
  if(T[nodeid].right != NIL) 
    preorder(T[nodeid].right);
}

void inorder(int nodeid) {
  
  if(T[nodeid].left != NIL)
    inorder(T[nodeid].left);
  
  printf(" %d",nodeid);
  
  if(T[nodeid].right != NIL) 
    inorder(T[nodeid].right);
}		 

void postorder(int nodeid) {
  if(T[nodeid].left != NIL)
    postorder(T[nodeid].left);
  
  if(T[nodeid].right != NIL)  
    postorder(T[nodeid].right);
  
  printf(" %d",nodeid);
}

int main(void) {
  
  int n,i,x;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++)
    T[i].parent = T[i].left = T[i].right = NIL; 
  
  for(i=0;i<n;i++) {
    scanf("%d",&x);
    scanf("%d%d",&T[x].left,&T[x].right);
    T[T[x].left].parent = x; 
    T[T[x].right].parent = x;
  }
  
  for(i=0;i<n;i++) 
    if(T[i].parent == NIL) 
      break;
  
  printf("Preorder\n");
  preorder(i);
  printf("\nInorder\n");
  inorder(i);
  printf("\nPostorder\n");
  postorder(i);
  printf("\n");
  
  return 0;    
  
}  