import java.util.*; class Tree { private Cell tree; public static Tree empty() { return new Tree(null); } private Tree(Cell l) { tree=l; } public int item() { return tree.item; } public Tree left() { return new Tree(tree.left); } public Tree right() { return new Tree(tree.right); } public static Tree make(int n,Tree l,Tree r) { return new Tree(new Cell(n, l.tree,r.tree)); } public boolean isEmpty() { return tree==null; } public String toString() { return treeString("",tree); } private static String treeString(String indent,Cell tree) { if(tree==null) return "\n"; else if(tree.left==null&&tree.right==null) return indent+tree.item+"\n"; else return treeString(indent+" ",tree.right)+ indent+tree.item+"\n"+ treeString(indent+" ",tree.left); } private static class Cell { int item; Cell left,right; Cell(int n,Cell l,Cell r) { item=n; left=l; right=r; } } }