class Solution {
public:
int dfs(TreeNode* root,int u){
if(!root)return 0;
u=u*10+root->val;
if(!root->left&&!root->right) return u;
return dfs(root->left,u)+dfs(root->right,u);
}
int sumNumbers(TreeNode* root) {
return dfs(root,0);
}
};