bool isSameTree(TreeNode* p, TreeNode* q) {
if(!p&&!q) return true;
if(p&&q) return (p->val==q->val? true:false)&&isSameTree(p->left,q->left)&&isSameTree(p->right,q->right);
return false;
}
if(!p&&!q) return true;
if(p&&q) return (p->val==q->val? true:false)&&isSameTree(p->left,q->left)&&isSameTree(p->right,q->right);
return false;
}