def print_treap(root):
    def dfs_print(root):
        if root is None:
            return
        dfs_print(root.left)
        print(str(root.key) + ' ', end='')
        dfs_print(root.right)

    dfs_print(root)
    print()