#include <stdio.h>

int N;
int left[26], right[26];

void preorder(int x) {
  printf(" %d", x);
  if(left[x] != -1) preorder(left[x]);
  if(right[x] != -1) preorder(right[x]);
}
void inorder(int x) {
  if(left[x] != -1) inorder(left[x]);
  printf(" %d", x);
  if(right[x] != -1) inorder(right[x]);
}
void postorder(int x) {
  if(left[x] != -1) postorder(left[x]);
  if(right[x] != -1) postorder(right[x]);
  printf(" %d", x);
}

int main() {
  int i,j;
  int isRoot[26];
  scanf("%d", &N);
  for(i = 0; i < N; ++i) {
    left[i] = right[i] = -1;
    isRoot[i] = 1;
  }

  for(i = 0; i < N; ++i) {
    int id  ;
    scanf("%d", &id);
    scanf("%d %d", left+id, right+id);
    if(left[id] != -1) isRoot[left[id]] = 0;
    if(right[id] != -1) isRoot[right[id]] = 0;
  }
  for(i = 0; i < N; ++i) {
    if(isRoot[i]) {
      printf("Preorder\n");
      preorder(i); printf("\n");
      printf("Inorder\n");
      inorder(i); printf("\n");
      printf("Postorder\n");
      postorder(i); printf("\n");
      break;
    }
  }

  return 0;
}