import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        BinaryTree binaryTree = new BinaryTree();
        Scanner scanner = new Scanner(System.in);

    //    System.out.println("Enter values to create a binary tree (enter -1 to stop):");

        int value;
        do {
       //     System.out.print("Enter a value (-1 to stop): ");
            value = scanner.nextInt();

            if (value != -1) {
                binaryTree.insert(value);
                binaryTree.displayBinaryTree(); // Display the binary tree after each insertion
            }
        } while (value != -1);

        scanner.close();}
}
class TreeNode {
    int data;
    TreeNode left, right;

    public TreeNode(int item) {
        data = item;
        left = right = null;}}
class BinaryTree {
    TreeNode root;
    public BinaryTree() {
        root = null;}
    void insert(int value) {
        root = insertRec(root, value);}
    TreeNode insertRec(TreeNode root, int value) {
        if (root == null) {
            root = new TreeNode(value);
            return root;}
        if (value < root.data) {
            root.left = insertRec(root.left, value);
        } else if (value > root.data) {
            root.right = insertRec(root.right, value);
        }

        return root;
    }

    void displayTree(TreeNode root, String indent, boolean last) {
        if (root != null) {
            System.out.print(indent);
            if (last) {
                System.out.print("└─");
                indent += "  ";
            } else {
                System.out.print("├─");
                indent += "│ ";
            }

            System.out.println(root.data);

            displayTree(root.left, indent, false);
            displayTree(root.right, indent, true);
        }
    }

    void displayBinaryTree() {
    //    System.out.println("Binary Tree:");
        displayTree(root, "", true);
        System.out.println();
    }
}

