题目描述
After you finished the simple task, Mr. Ye give you a new task.
Every zstu acmer knows bbs.zjchess.com. But do you know how many tasks the users on bbs.zjchess.com finish every day?
Supposed that there are 4 web pages on bbs.zjchess.com,p1,p2,p3,p4.
And we can read from the log file:
p1 - 10.17.12.21
p2 p1 10.17.12.21
p3 p2 10.17.12.21
p4 p3 10.17.12.21
p1 - 10.17.12.21
p2 p1 10.17.12.21
p3 p2 10.17.12.21
p4 p3 10.17.12.21
p1 - 10.17.12.21
p4 p1 10.17.12.21
p1 - 10.17.12.21
p2 p3 10.10.10.1
p2 p1 10.17.12.21
p1 - 10.11.16.23
p4 p2 10.10.10.1
p4 p1 10.11.16.23
We can see there are 3 tasks finished by the user who comes from 10.17.12.21:
(1) -(begin) -> p1 -> p2 -> p3 -> p4
-(begin) -> p1 -> p2 -> p3 -> p4 (same as before)
(2) -(begin) -> p1 -> p4
(3) -(begin) -> p1 -> p2
1 tasks finished by the user who comes from 10.10.10.1:
(1) p3 -> p2 -> p4
1 tasks finished by the user who comes from 10.11.16.23:
(1) -(begin) -> p1 -> p4
So we say there are 5 tasks(3+1+1) finished by all the users.
输入
The input file contains several test cases. Each test cases starts one integer number n (n <= 100), then n lines ffollows. Each line has 3 parts: destination page ,source page and ip.(pages no more than 50,p1,p2...p50, "-" is a blank page.)
输出
For each test case output on a single line the number of tasks.
16
p1 - 10.17.12.21
p2 p1 10.17.12.21
p3 p2 10.17.12.21
p4 p3 10.17.12.21
p1 - 10.17.12.21
p2 p1 10.17.12.21
p3 p2 10.17.12.21
p4 p3 10.17.12.21
p1 - 10.17.12.21
p4 p1 10.17.12.21
p1 - 10.17.12.21
p2 p3 10.10.10.1
p2 p1 10.17.12.21
p1 - 10.11.16.23
p4 p2 10.10.10.1
p4 p1 10.11.16.23
提示
if one ip view the pages in the order:
p2 p1 p1 -> p2
p3 p2 p2 -> p3 one task finished,
p3 p1 p1 -> p3 new task begin, because the beginning page p1 is not the page p3