#!/usr/bin/env python3
import sys,lzma,collections,os,math,itertools

def parse(path):
    op = lzma.open if path.endswith('.xz') else open
    n=m=0; hist=collections.Counter(); pos=neg=0; deg=collections.Counter(); clauses=[]
    with op(path,'rt',encoding='ascii',errors='ignore') as f:
      for line in f:
        if not line or line[0] in 'c%0\n': continue
        if line[0]=='p':
          sp=line.split(); n=int(sp[2]); m=int(sp[3]); continue
        lits=list(map(int,line.split()))
        if not lits: continue
        if lits[-1]==0: lits=lits[:-1]
        hist[len(lits)]+=1
        for l in lits:
          if l>0: pos+=1
          else: neg+=1
          deg[abs(l)]+=1
        if len(clauses)<20000: clauses.append(tuple(lits))
    return n,m,hist,pos,neg,deg,clauses

for p in sys.argv[1:]:
    n,m,h,pos,neg,deg,clauses=parse(p)
    name=os.path.basename(p)
    ds=[deg[i] for i in range(1,n+1)] if n else []
    print(name, 'vars',n,'clauses',m,'hist',dict(sorted(h.items())),'pos%', round(pos/(pos+neg),3) if pos+neg else 0,'deg', (min(ds), max(ds), round(sum(ds)/len(ds),2)) if ds else '')
