w = input()
n = int(input())
o = {w}
for i in range(n):
ww, l = input().split()
if l == w:
w = ww
o.add(w)
print(w)
print(len(o))
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
2708 KB |
Output is correct |
2 |
Correct |
13 ms |
2792 KB |
Output is correct |
3 |
Correct |
12 ms |
2776 KB |
Output is correct |
4 |
Correct |
10 ms |
2772 KB |
Output is correct |
5 |
Correct |
12 ms |
2824 KB |
Output is correct |
6 |
Correct |
14 ms |
2772 KB |
Output is correct |
7 |
Correct |
14 ms |
2828 KB |
Output is correct |
8 |
Correct |
14 ms |
2772 KB |
Output is correct |
9 |
Correct |
14 ms |
2772 KB |
Output is correct |
10 |
Correct |
11 ms |
2704 KB |
Output is correct |