class Solution {
public:
    int n;
    vector<int> p;
    vector<vector<int>> res;
    void path(TreeNode* root,int expectNumber){
        if(!root){
            return;
        }
        n+=root->val;
        p.push_back(root->val);
        if(root->left){
            path(root->left,expectNumber);
        }
        if(root->right){
            path(root->right,expectNumber);
        }
        if(n==expectNumber && !root->left && !root->right){
            res.push_back(p);
        }
        n-=root->val;
        p.pop_back();
        return;
    }
    vector<vector<int>> FindPath(TreeNode* root,int expectNumber) {
        path(root,expectNumber);
        return res;
    }
};