#!/usr/bin/env python3
import collections
import lzma
import sys


def read(path):
    op = lzma.open if path.endswith(".xz") else open
    with op(path, "rt") as f:
        n = m = 0
        hist = collections.Counter()
        pos = collections.Counter()
        neg = collections.Counter()
        units = []
        binaries = []
        for line in f:
            if not line or line[0] == "c":
                continue
            if line[0] == "p":
                _, _, n, m = line.split()[:4]
                n, m = int(n), int(m)
                continue
            lits = [int(x) for x in line.split() if x != "0"]
            if not lits:
                continue
            hist[len(lits)] += 1
            if len(lits) == 1:
                units.append(lits[0])
            if len(lits) == 2:
                binaries.append(tuple(lits))
            for lit in lits:
                if lit > 0:
                    pos[lit] += 1
                else:
                    neg[-lit] += 1
        return n, m, hist, units, binaries, pos, neg


for path in sys.argv[1:]:
    n, m, hist, units, binaries, pos, neg = read(path)
    mentioned = len(set(pos) | set(neg))
    pure_pos = sum(1 for v in range(1, n + 1) if pos[v] and not neg[v])
    pure_neg = sum(1 for v in range(1, n + 1) if neg[v] and not pos[v])
    print(path.split("/")[-1])
    print(" vars", n, "clauses", m, "mentioned", mentioned, "hist", dict(sorted(hist.items())))
    print(" units", len(units), units[:20], "binaries", len(binaries))
    print(" pure+", pure_pos, "pure-", pure_neg)
    print(" max var pos/neg", max(pos or {0: 0}), max(neg or {0: 0}))
