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

#define N 25
#define NIL -1


typedef struct {
  int pare, sib, left, right;
}Node;

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

Node node[N];
int n = 0;


int main () {
  
  int i, j, k = 0, m = 0, child = 0, x = 0, root = 0;

  scanf("%d", &n);


  for(i = 0 ; i < n ; i++) {
    node[i].pare = NIL;
    node[i].sib = NIL;
    node[i].left = NIL;
    node[i].right = NIL;
  }
  
  for(i = 0 ; i < n ; i++){
    
    scanf("%d",&m);

    for(j = 0 ; j < 2 ; j++) {
      scanf("%d",&child);
      if(j == 0) {
	x = child;
	node[m].left = child;
      }
      else {
	node[child].sib = x;
	node[x].sib = child;
	node[m].right = child;
      }
      node[child].pare = m;
    }
  }


  for(i = 0 ; i < n ; i++) {
    if(node[i].pare == NIL) root = i;
  }

  

  printf("Preorder\n");
  Preorder(root);
  printf("\n");

  printf("Inorder\n");
  Inorder(root);
  printf("\n");

  printf("Postorder\n");
  Postorder(root);
  printf("\n");
  
  return 0;
}


void Preorder(x) {

  if(x != NIL) {
    printf(" %d",x);
    Preorder(node[x].left);
    Preorder(node[x].right);
  }
    
}


void Inorder(x) {

  if(x != NIL) {
    Inorder(node[x].left);
    printf(" %d",x);
    Inorder(node[x].right);
  }
}


void Postorder(x) {

  if(x != NIL) {
    Postorder(node[x].left);
    Postorder(node[x].right);
    printf(" %d",x);
  }
}

