input
output
select t.n ,case when t.p is null then "Root" when t.n in (select t1.p from bst t1 where t1.p is not null) then "Inner" else "Leaf" end as "result" from bst t order by t.n