class Node:
    def __init__(self, val):
        self.val = val
        self.left = None
        self.right = None
 
def ceil(root, key):
    # Base case
    if not root:
        return -1
 
    # If key is present at root
    if root.val == key:
        return root.val
 
    # If key is smaller than root's value, ceil must be in right subtree
    if root.val < key:
        return ceil(root.right, key)
 
    # If key is greater than root's value, ceil may be in left subtree or root itself
    left_ceil = ceil(root.left, key)
    return left_ceil if left_ceil >= key else root.val
 
# Create a BST
root = Node(8)
root.left = Node(4)
root.right = Node(12)
root.left.left = Node(2)
root.left.right = Node(6)
root.right.left = Node(10)
root.right.right = Node(14)
 
# Find the ceil value of 5
ceil_val = ceil(root, 5)
print("The ceil value of 5 is:", ceil_val)
 
# Find the ceil value of 15
ceil_val = ceil(root, 15)
print("The ceil value of 15 is:", ceil_val)
 
# Find the ceil value of 9
ceil_val = ceil(root, 9)
print("The ceil value of 9 is:", ceil_val)