UVA12459 Bees' ancestors

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=279&page=show_problem&problem=3890 [PDF](https://uva.onlinejudge.org/external/124/p12459.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12459/167995d3f3e4ddcc6ee5bbcf84681bd40654189d.png)

Input Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12459/24745db70deae69cae184ccac265cf416b3c6e8d.png)

Output Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA12459/7aef34bd0ff0bd786180f70d20f345d7f5edfaf1.png)