n = int(input()) sub = {} prsn = {} for i in range(n): s = input().split() suma = 0 for j in range(1, len(s)): x, y = s[j].split(':') y = float(y) suma += y if x not in sub: sub.update({x: [y, 1]}) else: sub[x][0] += y sub[x][1] += 1 prsn.update({s[0]: suma/(len(s)-1)}) for i in sorted(prsn.keys()): print(i, prsn[i]) for i in sorted(sub.keys()): print(i, sub[i][0]/sub[i][1])