문제
각 종류의 의상을 입는 경우의 수를 곱해주면 된다.
즉, 해당 종류의 의상 수 + 1(해당 종류를 입지 않는 경우)를 의상의 종류 모두 곱해준 뒤,
1을 빼주면 된다(알몸인 경우 제외를 위해 -1을 해준다.).
import sys
input = sys.stdin.readline
for _ in range(int(input())):
  dress = dict()
  n = int(input())
  if n == 0:
    print(0)
    continue
  for _ in range(n):
    name, type = map(str, input().split())
    if type in dress.keys():
      dress[type] += 1
    else:
      dress[type] = 1
    
    ans = 1
    for tmp in dress.keys():
      ans *= dress[tmp] + 1
    ans -= 1
  print(ans)