class Solution:

```
def left_root_right(self, root,List):
if root == None:
return
self.left_root_right(root.left,List)
List.append(1)
List.append(root.val)
self.left_root_right(root.right,List)
List.append(2)
def isSameTree(self, p, q):
tree1=[]
tree2=[]
self.left_root_right(p,tree1)
self.left_root_right(q,tree2)
if tree1==tree2:
return True
else:
return False
```