#include <iostream>

using namespace std;

struct TNode {
  int m_nVal;
  TNode *m_pLeft;
  TNode *m_pRight;
};

bool hasAllNodes(TNode *pTree1, TNode *pTree2) {
  if(pTree2==NULL)
    return true;

  if(pTree1==NULL)
    return false;

  if(pTree1->m_nVal!=pTree2->m_nVal)
    return false;

  bool hasL = true;
  if(pTree2->m_pLeft)
    hasL = hasAllNodes(pTree1->m_pLeft, pTree2->m_pLeft);

  bool hasR = true;
  if(pTree2->m_pRight)
    hasR = hasAllNodes(pTree1->m_pRight, pTree2->m_pRight);

  return hasL && hasR;
}

bool isSubTree(TNode *pTree1, TNode *pTree2) {
  if(pTree2==NULL)
    return true;

  if(pTree1==NULL)
    return false;

  if(pTree1->m_nVal==pTree2->m_nVal) {
    return hasAllNodes(pTree1, pTree2);
  } else {
    return isSubTree(pTree1->m_pLeft, pTree2) || isSubTree(pTree1->m_pRight, pTree2);
  }
}

int main(int argc, char **argv) {

  return 0;
}
