class TreeNode {
 int data;
 TreeNode left;
 TreeNode right;
}

class BinarySearchTree{
 private TreeNode root = new TreeNode();
 
 public void insertBST(int x) {
  TreeNode p = root;
  TreeNode q=null;
  while(p!=null) {
   if(x==p.data) return;
   q=p;
   if(x<p.data) p=p.left;
   else p=p.right;
  }
  TreeNode newNode = new TreeNode();
  newNode.>  newNode.left = null;
  newNode.right = null;
  if(root==null) root = newNode;
  else if (x<q.data) q.left = newNode;
  else q.right = newNode;
  return;
 }
 
 public TreeNode searchBST(int x) {
  TreeNode p = root;
  while(p!=null){
   if(x==p.data) return p;
   else if(x<p.data) p=p.left;
   else  p=p.right;
  }
  return p;
 }
 
 public void inorder(TreeNode root) {
  if(root!=null) {
   inorder(root.left);
   System.out.printf(" %d", root.data);
   inorder(root.right);
  }
 }
 
 public void printBST() {
  inorder(root);
  System.out.println();
 }
}