class Solution {
public:
	vector<vector<int> > res;

	void find(TreeNode* p,vector<int> rec,int target){
		vector<int> record;
		for(auto x : rec) record.push_back(x);
		record.push_back(p->val);
		if(p->left != NULL) find(p->left,record,target);
		if(p->right != NULL) find(p->right,record,target);
		if(p->left == NULL && p->right == NULL){
			int sum = 0;
			for(auto x : record) sum += x;
			if(sum == target) res.push_back(record);
		}
		return;
	}

    vector<vector<int>> FindPath(TreeNode* root,int expectNumber) {
        vector<int> temp;
		if(root == NULL) return {};
		temp.push_back(root->val);
		if(root->val == expectNumber && root->left==NULL && root->right == NULL) res.push_back(temp);
		if(root->left != NULL) find(root->left,temp,expectNumber);
		if(root->right != NULL) find(root->right,temp,expectNumber);
		return res;
    }
};