#!/usr/bin/env python3
import lzma, sys, collections
for fn in sys.argv[1:]:
    opener = lzma.open if fn.endswith('.xz') else open
    with opener(fn, 'rt') as f:
        clauses=[]; n=m=0
        for line in f:
            if line.startswith('p'):
                _,_,n,m=line.split()[:4]; n=int(n); m=int(m)
            elif line.strip() and line[0] not in 'c%':
                clauses.append([int(x) for x in line.split()[:-1]])
    blocks=[]; i=0
    while i<len(clauses):
        ps=tuple(sorted({(abs(x)+1)//2 for x in clauses[i]}))
        j=i+1
        while j<len(clauses) and tuple(sorted({(abs(x)+1)//2 for x in clauses[j]}))==ps:
            j+=1
        blocks.append((ps,j-i))
        i=j
    print(fn, 'vars', n, 'clauses', m, 'blocks', len(blocks), collections.Counter(s for _,s in blocks))
