#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None
#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
# 
# @param pRoot TreeNode类 
# @return int整型二维数组
#
class Solution:
    def Print(self , pRoot: TreeNode) -> List[List[int]]:
        # write code here
        list2proot = [pRoot]
        result = []
        if not pRoot:
            return None
        result.append([list2proot[0].val])
        while list2proot:
            temp = []
            temp2 = []  # 这两个列表初始化要放在遍历每一层节点之前,即for循环之前
            for ele in list2proot:
                if ele.left:
                    temp.append(ele.left)
                    temp2.append(ele.left.val)
                if ele.right:
                    temp.append(ele.right)
                    temp2.append(ele.right.val)
            list2proot = temp
            if temp2:
                result.append(temp2)
        return result