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 |
33 ms |
18220 KB |
Output is correct |
2 |
Correct |
28 ms |
18168 KB |
Output is correct |
3 |
Correct |
29 ms |
18228 KB |
Output is correct |
4 |
Correct |
34 ms |
18192 KB |
Output is correct |
5 |
Correct |
30 ms |
18124 KB |
Output is correct |
6 |
Correct |
27 ms |
18228 KB |
Output is correct |
7 |
Correct |
33 ms |
18156 KB |
Output is correct |
8 |
Correct |
28 ms |
18172 KB |
Output is correct |
9 |
Correct |
29 ms |
18180 KB |
Output is correct |
10 |
Correct |
28 ms |
18240 KB |
Output is correct |