# CPU: 0.09 s
for _ in range(int(input())):
    print(len(set(input() for _ in range(int(input())))))

# CPU: 0.09 s
for _ in range(int(input())):
    print(len(set(input() for _ in range(int(input())))))

# CPU: 0.09 s