#-*- coding: UTF-8 -*-
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def invertTree(self, root):
if root==None:return None
tempRoot=root.left
root.left=root.right
root.right=tempRoot
self.invertTree(root.right)
self.invertTree(root.left)
return root