10887 - Concatenation of Languages Solution Python

totalCase = int(input())
i = 1
while i <= totalCase:
m, n = [int(x) for x in input().split()]
mySet1 = set()
for j in range(m):
mySet1.add(input().strip())
mySet2 = set()
for j in range(n):
mySet2.add(input().strip())
mySet = set()
for x in mySet1:
for y in mySet2:
mySet.add(x + y)
print(f"Case {i}: {len(mySet)}")
i += 1

Comments

Popular posts from this blog

uva 679 - Dropping Balls Solution

uva 481 - What Goes Up Solution

uva-10077 Solution --- The Stern-Brocot Number System