import sys from collections import defaultdict as DD D = DD(set) S = set() for i in sys.stdin.read().strip().split('\n'): a, b = i.split("-") D[a].add(b) D[b].add(a) S.add(a) S.add(b) G = set() m = 0 def grow(group:set[str], l:int): global m key = ','.join(sorted(group)) if key in G: return G.add(key) if l>m: print(l, key) m = l rest = S - group for r in rest: if len(group & D[r]) == l: ng = group.copy() ng.add(r) yield (l+1, ng) yield from grow(ng, l+1) for a, B in D.items(): for b in B: for i,s in grow({a,b},2): pass