#!/usr/bin/env python3
import sys,lzma,collections,math
for fn in sys.argv[1:]:
    op=lzma.open if fn.endswith('.xz') else open
    n=m=0; dist=collections.Counter(); pos=neg=mix=0; deg=collections.Counter(); clauses=[]
    with op(fn,'rt') as f:
        for line in f:
            if not line or line[0] in 'c%0': continue
            if line[0]=='p':
                p=line.split(); n=int(p[2]); m=int(p[3]); continue
            lits=[int(x) for x in line.split() if x!='0']
            if not lits: continue
            dist[len(lits)]+=1
            if all(x>0 for x in lits): pos+=1
            elif all(x<0 for x in lits): neg+=1
            else: mix+=1
            for x in lits: deg[abs(x)]+=1
            clauses.append(tuple(lits))
    print(fn, 'n',n,'m',m,'dist',dict(sorted(dist.items())),'pos',pos,'neg',neg,'mix',mix,'deg', (min(deg.values()), sum(deg.values())/n, max(deg.values())))
    for k in sorted(dist):
        sample=next(c for c in clauses if len(c)==k)
        print(' sample',k,sample)
