- 의상을 종류별로 구분해서 딕셔너리에 저장한 다음 입을 수 있는 경우의 수를 세어주면 된다. 입을 수 있는 경우의 수는 딕셔너리에 저장된
value
에 1을 더해 모두 곱해준 다음 1을 빼주면 된다.
T = int(input())
for _ in range(T):
n = int(input())
clothes = []
dict = {}
for i in range(n):
clothes.append(list(map(str, input().split())))
if clothes[i][1] not in dict:
dict[clothes[i][1]] = 1
else:
dict[clothes[i][1]] += 1
result = 1
for i in dict.values():
result *= (i+1)
print(result - 1)