#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class RootedNode{
public:
	vector<ll> parent;
	ll depth,dist;
	RootedNode():depth(0),dist(0){}
};

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	map<int,int> input;
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		input[v]++;
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

class RootedTree{
	int parent_size;

	void DFS(ConnectNodeInfo& connection,ll child,ll parent,ll dep,ll dist){
		node[child].parent[0] = parent;
		node[child].depth = dep;
		node[child].dist = dist;
		preorder.push_back(child);

		int num=0;
		for(int i = 0;i < connection[child].size();i++){
			int cn = connection[child][i].first;
			if(!i && cn==-1){
				inorder.push_back(child);
			}
			if(cn!=-1){
				DFS(connection,connection[child][i].first,child,dep+1,dist+connection[child][i].second);
				num++;
			}
			if(!i && cn!=-1) inorder.push_back(child);
		}
		//if(!num) inorder.push_back(child);
		postorder.push_back(child);
	}
public:
	vector<RootedNode> node;
	vector<int> preorder,inorder,postorder;

	RootedTree(ConnectNodeInfo& connection,int root){
		auto connection_size = connection.size();
		parent_size = 1;
		while((1LL<<parent_size)<connection_size) parent_size++;

		node.resize(connection_size);
		for(auto& x:node) x.parent.resize(parent_size,-1);
		DFS(connection,root,-1,0,0);
		for(int k=0;k<parent_size-1;k++){
			for(int v=0,ev=connection_size;v<ev;v++){
				if(node[v].parent[k] < 0) node[v].parent[k+1] = -1;
				else node[v].parent[k+1] = node[node[v].parent[k]].parent[k];
			}
		}
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N=in();
	ConnectNodeInfo connect(N);
	REP(i,N){
		int u=in(),v1=in(),v2=in();
		connect.AddDirectionalConnection(u,v1,1);
		connect.AddDirectionalConnection(u,v2,1);
	}
	int root;
	REP(i,N){
		if(connect.input[i]==0){
			root = i;
			break;
		}
	}
	RootedTree tree(connect,root);

	out("Preorder");
	REP(i,N){
		cout << ' ' << tree.preorder[i];
	}
	cout << endl;
	out("Inorder");
	REP(i,N){
		cout << ' ' << tree.inorder[i];
	}
	cout << endl;
	out("Postorder");
	REP(i,N){
		cout << ' ' << tree.postorder[i];
	}
	cout << endl;
	
	return 0;
}



Measured memory_bytes: 3204