d={}
sp_lat=[]
for x in range(int(input())):
eng,*lat=input().split()
s=lat[1::]
d[eng]=s
for x in range(len(s)):
str=s[x].replace(',','')
s[x]=str
sp_lat.append(s[x])
sp_lat.sort()
uniq_sp_lat=list(set(sp_lat))
d2={}
for x in range(len(uniq_sp_lat)):
d2[uniq_sp_lat[x]]=[]
for key, value in d.items():
if uniq_sp_lat[x] in value:
d2[uniq_sp_lat[x]].append(key)
#print(d2)
print(len(d2))
for k,v in d2.items():
print(k,'-',(', '.join(v)))