class Solution:
def bstToGst(self, root: TreeNode) -> TreeNode:
def dfs(root):
if root == None:
return
dfs(root.right)
tmp[0] += root.val
root.val = tmp[0]
dfs(root.left)
tmp = [0]
dfs(root)
return root