#include <stdio.h>
#define Num 100000
#define LAST -1

struct Node {
    int parent;
    int left;
    int right;
};
struct Node Tree[Num];

void Pre_Order(int a){

    if(a == LAST)
        return;
    printf(" %d" , a);
    Pre_Order(Tree[a].left);
    Pre_Order(Tree[a].right);
}


void In_Order(int b) {

    if(b == LAST)
        return;
    In_Order(Tree[b].left);
    printf(" %d" , b);
    In_Order(Tree[b].right);
}


void Post_Order(int c) {
    if(c == LAST)
        return;
    Post_Order(Tree[c].left);
    Post_Order(Tree[c].right);
    printf(" %d" , c);
}

int main(void)
{
    int n , i;
    int vertex , left , right;
    int root;
    
    scanf("%d" , &n);
    

    for(i = 0 ; i < n ; i++)
        Tree[i].parent = LAST;

    for(i = 0 ; i < n ; i++) {
        scanf("%d %d %d" , &vertex , &left , &right);
        Tree[vertex].left  = left;
        Tree[vertex].right = right;
        /*親を設定*/
        if(left != LAST)
            Tree[left].parent  = vertex;
        if(right != LAST)
            Tree[right].parent = vertex;
    }
    /*親はLASTにされている*/
    for(i = 0 ; i < n ; i++)
        if(Tree[i].parent == LAST)
            root = i;
    
    puts("Preorder");
    Pre_Order(root);
    printf("\n");
    
    puts("Inorder");
    In_Order(root);
    printf("\n");
    
    puts("Postorder");
    Post_Order(root);
    printf("\n");
    
    return 0;
}

