#!/usr/bin/env python3
import sys,lzma,collections,os,re
path=sys.argv[1]
openf=lzma.open if path.endswith('.xz') else open
clauses=[]; comments=[]; n=m=None
with openf(path,'rt') as f:
  for line in f:
    if line.startswith('c'):
      comments.append(line.strip()); continue
    if not line.strip(): continue
    if line.startswith('p'):
      n=int(line.split()[2]); m=int(line.split()[3]); continue
    clauses.append(tuple(map(int,line.split()[:-1])))
print('file',os.path.basename(path),'n',n,'m',m,'comments',comments[:3])
print('sizes',collections.Counter(map(len,clauses)))
for i,c in enumerate(clauses[:220]): print(i+1,c)
