class TreeNode
{
	TreeNode left_  = null;
	TreeNode right_ = null;
	public TreeNode left{
		get { return left_;   }
	}
	public TreeNode right{
		get { return right_;   }
	}
	
	public void setLeftNode  (ref TreeNode node) { left_  = node; }
	public void setRightNode (ref TreeNode node) { right_ = node; }
	
	int key_;
	public int key {
		get { return key_;  }
	}
	public TreeNode (int i) { key_ = i;}
};

class InputInfo
{
	int id_      = 0;
	int leftId_  = 0;
	int rightId_ = 0;
	
	public int id {
		get { return id_; }
	}
	public int leftId {
		get { return leftId_; }
	}
	public int rightId {
		get { return rightId_; }
	}
	
	public static InputInfo parseInput()
	{
		string   inputStr = System.Console.ReadLine();
		string[] splitStr = inputStr.Split(' ');
		
		int[] input = new int[splitStr.Length];
		for(int i = 0; i < splitStr.Length; ++i) {
			input[i] = int.Parse(splitStr[i]);
		}
		InputInfo ret = new InputInfo(input);
		return ret;
	}
	
	public InputInfo(int[] input)
	{
		if (input.Length != 3) {
			System.Console.WriteLine("input: ??? WrongFormat");
			return;
		}
		id_      = input[0];
		leftId_  = input[1];
		rightId_ = input[2];
	}
};
abstract class Traverser {
	int[] visitedNodeHist;
	int count = 0;
	protected void pushHist(int key) {
		visitedNodeHist[count++] = key;
	}
	
	protected abstract void visitArgo(TreeNode visitedNode); // ?????????????????¢?´¢?????????????£?
	public bool run(TreeNode visitedNode, bool rec = false) // ?????°?????????????????¢?´¢ ??¢?´¢???????¶?????????§????£?
	{
		bool ret = false;
		if (visitedNode != null) {
			visitArgo(visitedNode);
		}
		if (rec == false) {
			if (count == visitedNodeHist.Length) { // ??¨??¢?´¢??§????????????
				for (int i = 0; i < visitedNodeHist.Length; ++i) {
					System.Console.Write(" {0}", visitedNodeHist[i]);
				}
				ret = true;
			}
			count = 0;
		}
		return ret;
	}
	
	public Traverser(int i) {visitedNodeHist = new int[i];}
};
class PreOrderTraverser : Traverser {
	protected override void visitArgo(TreeNode visitedNode) {
		pushHist(visitedNode.key);
		run(visitedNode.left, true);
		run(visitedNode.right, true);
	}
	public PreOrderTraverser(int i) : base(i){}
};
class InOrderTraverser : Traverser {
	protected override void visitArgo(TreeNode visitedNode) {
		run(visitedNode.left, true);
		pushHist(visitedNode.key);
		run(visitedNode.right, true);
	}
	public InOrderTraverser(int i) : base(i){}
};
class PostOrderTraverser : Traverser {
	protected override void visitArgo(TreeNode visitedNode) {
		run(visitedNode.left, true);
		run(visitedNode.right, true);
		pushHist(visitedNode.key);
	}
	public PostOrderTraverser(int i) : base(i){}
};

class Tree
{
	public static void Main()
	{
		int inputNum = int.Parse(System.Console.ReadLine());
		
		TreeNode[] tn = new TreeNode[inputNum]; // ???????????????
		for (int i = 0; i < inputNum; ++i) {
			tn[i] = new TreeNode(i);
		}
		
		//??\?¶?
		for (int i = 0; i < inputNum; ++i) {
			InputInfo input = InputInfo.parseInput();
			if (input.leftId  >= 0) tn[input.id].setLeftNode (ref tn[input.leftId ]);
			if (input.rightId >= 0) tn[input.id].setRightNode(ref tn[input.rightId]);
		}
		
		int root = 0;
		System.Console.WriteLine("Preorder");
		Traverser prOT = new PreOrderTraverser(inputNum);
		while (prOT.run(tn[root]) != true) ++root; //?????¢???
		System.Console.WriteLine("");
		
		System.Console.WriteLine("Inorder");
		Traverser inOT = new InOrderTraverser(inputNum);
		inOT.run(tn[root]);
		System.Console.WriteLine("");
		
		System.Console.WriteLine("Postorder");
		Traverser poOT = new PostOrderTraverser(inputNum);
		poOT.run(tn[root]);
		System.Console.WriteLine("");
	}
}

Measured memory_bytes: 9088