import lzma,sys,itertools,collections,random
path=sys.argv[1]
cla=[]; n=0
for line in lzma.open(path,'rt'):
 if line[0]=='p': n=int(line.split()[2]); continue
 if line[0]=='c': continue
 c=[int(x) for x in line.split() if x!='0']
 if c: cla.append(c)
neg=set(); groups=[]; used=set()
for c in cla:
 if len(c)==2 and c[0]<0 and c[1]<0:
  a,b=sorted([-c[0],-c[1]]); neg.add((a,b))
for c in cla:
 if 2<=len(c)<=192 and all(x>0 for x in c):
  ok=not any(v in used for v in c) and all((min(a,b),max(a,b)) in neg for a,b in itertools.combinations(c,2))
  if ok:
   groups.append(c); used.update(c)
print(len(groups),sum(map(len,groups)),n)
def count(sel):
 val=[False]*(n+1)
 for g,p in zip(groups,sel): val[g[p%len(g)]]=True
 uns=0
 for c in cla:
  if not any((l>0 and val[l]) or (l<0 and not val[-l]) for l in c): uns+=1
 return uns
for p in range(30): print('const',p,count([p]*len(groups)))
# row/color same maybe variable offset mod group size for each group
best=10**9; bests=None
for t in range(1000):
 sel=[random.randrange(len(g)) for g in groups]
 u=count(sel)
 if u<best: best=u; print('rand',t,best)
