﻿ N-B-U-T Online Judge :: [1114] Alice's Puppets
• ### [1114] Alice's Puppets

• 时间限制: 1000 ms　内存限制: 65535 K
• 问题描述
• Alice Margatroid (アリス·マーガトロイド) can control puppets. What's more, she can control her pupet to control other pupets.

The puppets she controls directly called the first-level puppet. And the puppets which are controlled by the first-level puppets are called the second-level puppet. So as the third, fourth and the ith-level.
Now your task is to tell me each puppet is what level.

• 输入
• This problem contains several cases.
The first line of each case is an integer N (0 ＜ N ≤ 1000), indicates the number of puppets.
Then N lines follows. Each line has two strings, the name of the ith puppet and the controller's name. You can imagine if the controller is Alice, then the puppet is the first-level puppet.
Every controller's name will be all appeared as a puppet's name before except Alice. Each name is no longer then 20.
• 输出
• For each case, you should output every puppet's names and levels, and order by level. If two puppets have the same level, then order by lexicographic.
• 样例输入
• ```3
Blahblah Alice
Peps Blahblah
Grugru Alice
```
• 样例输出
• ```Blahblah 1
Grugru 1
Peps 2
```
• 提示
• `无`
• 来源
• `XadillaX`
• 操作
﻿