static void Main(string[] args)
        {
            int n     = int.Parse(Console.ReadLine());
            var nodes = MyEnumerable.Repeat(i => new Node(i), n).ToList();

            for (int i = 0; i < n; i++)
            {
                var input = Console.ReadLine().Split(' ').Select(int.Parse);
                int left  = input.ElementAt(1);
                int right = input.ElementAt(2);
                nodes[i].Id    = i;
                nodes[i].Left  = left;
                nodes[i].Right = right;

                if (left != -1)
                {
                    nodes[left].Parent = i;
                }
                if (right != -1)
                {
                    nodes[right].Parent = i;
                }
            }

            var rootNode = nodes.Where(node => node.Parent == -1).First();

            Console.WriteLine("Preorder");
            Console.WriteLine(string.Join(" ", PreParse(rootNode, nodes)));
            Console.WriteLine("");
            Console.WriteLine("Inorder");
            Console.WriteLine(string.Join(" ", InorderParse(rootNode, nodes)));
            Console.WriteLine("");
            Console.WriteLine("Postorder");
            Console.WriteLine(string.Join(" ", PostorderParse(rootNode, nodes)));
            Console.WriteLine("");
            Console.ReadLine();
        }