Manito Chains

No attempts yetTime limit1sMemory limit128 MB

Problem

N people are playing a Secret Santa (Manito) game. Each person receives a slip bearing the name of exactly one other person and secretly does a good deed for that person. No one ever receives their own name.

While watching the game, Sejong discovers the idea of a "Manito chain." Sejong does a good deed for Dongwoo, Dongwoo does one for Jaehyuk, Jaehyuk does one for Hoyong, and so on. If you keep following this trail, eventually someone does a good deed for Sejong, the person who started it. In other words, a closed chain of good deeds always forms and comes back around to its start. Such a chain may consist of just 2 people, or all N people may belong to a single chain.

Count how many such chains form among the N people, and print the answer.

Input

The input consists of several test cases.

The first line of each test case contains the number of people $N$ ($3 \le N \le 20$). If $N$ is $0$, it marks the end of the input and there is no further input after it.

Each of the following $N$ lines contains the names of two people separated by a space. Each line means "the first person does a good deed for the second person." Within a single test case, the names in the first position are all distinct, the names in the second position are all distinct, and no line contains the same name twice. Each name is at most 10 characters long.

Output

For each test case, print on one line the test case number (starting from 1) and the number of chains, separated by a space.