/*
 * function TreeNode(x) {
 *   this.val = x;
 *   this.left = null;
 *   this.right = null;
 * }
 */

/**
  * 
  * @param p TreeNode类 
  * @param q TreeNode类 
  * @return bool布尔型
  */
function isSameTree( p ,  q ) {
    // write code here
    if(!p || !q){
        return p===q
    }else if(p.val!==q.val){
        return false
    }
    return isSameTree(p.left,q.left)&&isSameTree(p.right,q.right)
}
module.exports = {
    isSameTree : isSameTree
};