# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
# 
# @param root TreeNode类 the root of binary tree
# @return int整型二维数组
#
class Solution:
    def threeOrders(self , root: TreeNode) -> List[List[int]]:
        # write code here #用几个全局变量来递归记录数据
        global first,mid,last;first=[];mid=[];last=[];res=[]
        def preOrder(root):
            if root:
                first.append(root.val)
                preOrder(root.left)
                preOrder(root.right)
            return first
        def inOrder(root):
            if  root:
                inOrder(root.left)
                mid.append(root.val)
                inOrder(root.right)
            return mid
        def lastOrder(root):
            if  root:
                lastOrder(root.left)
                lastOrder(root.right)
                last.append(root.val)
            return last
        res.append(preOrder(root))
        res.append(inOrder(root))
        res.append(lastOrder(root))
        return res