Hello. I have WA, although tests in examples are OK. My code here:
tests = int(input())
for test in range(tests):
n = int(input())
accounts = set()
for x in range(n):
a = tuple([str(x) for x in input().split()])
accounts.add(a)
if test != tests - 1:
empty_line = input()
accounts = list(accounts)
accounts.sort(key=lambda y: (y[0], y[1], y[2], y[3], y[4], y[5]))
owners = {}
if test == 0:
print()
for x in accounts:
owner = x[2]+x[3]+x[4]+x[5]
if owner not in owners:
owners[owner] = 1
else:
owners[owner] += 1
print(x[0], x[1], x[2], x[3], x[4], x[5], owners[owner])