#include <stdio.h>
#define MAX 100000

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

void Preorder(int);
void Inorder(int);
void Postorder(int);

Node T[MAX];
int c[2];
int n, count;

int main(){
  int l, m, i, j;

  scanf("%d", &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", &l);
    for(j = 0; j < 2; j++){
      scanf("%d", &c[j]);
      if(c[j] != -1){
	T[c[j]].parent = l;
	if(j == 0) T[l].left = c[j];
	else T[l].right = c[j];
      }
    }
  }

  for(i = 0; i < n; i++) if(T[i].parent == -1) m = i;
  
  printf("Preorder\n");
  count = 0;
  Preorder(m);
  printf("\n");

  printf("Inorder\n");
  count = 0;
  Inorder(m);
  printf("\n");

  printf("Postorder\n");
  count = 0;
  Postorder(m);
  printf("\n");
  
  return 0;
}

void Preorder(int u){
  if(u == -1) return;
  printf("%d", u);
  if(++count != n) printf(" ");
  Preorder(T[u].left);
  Preorder(T[u].right);
}

void Inorder(int u){
  if(u == -1) return;
  Inorder(T[u].left);
  printf("%d", u);
  if(++count != n) printf(" ");
  Inorder(T[u].right);
}

void Postorder(int u){
  if(u == -1) return;
  Postorder(T[u].left);
  Postorder(T[u].right);
  printf("%d", u);
  if(++count != n) printf(" ");
}