# Same as gl6_box.py but the blocks of x are listed in increasing exponent order
# (a K-equivalent representative: a permutation matrix in K reorders the blocks).
import sys, time
exec(open('/private/tmp/claude-501/-Users-miltonlin-Projects-Trees/f0f18b89-aa0d-4ce6-93d2-78c269eb7d7d/scratchpad/salvage/S1/engine.py').read())
p = int(sys.argv[1])
orbits = {'c1': (0, 0, 2), 'c2': (0, 1, 1), 'c3': (-1, 1, 2), 'c4': (-2, 2, 2)}
if len(sys.argv) > 2:
    orbits = {k: orbits[k] for k in sys.argv[2].split(',')}
R = {'R1': (0, 0, 0, 0, -1, -1), 'R2': (1, 0, 0, -1, -1, -1), 'R3': (1, 1, -1, -1, -1, -1)}
pred = lambda q: {'R1': (1, (q+1)*(q*q+1), 0, 0),
                  'R2': (q*(q+1)*(q*q+1), q**3*(q+1)**2*(q*q+1), (q+1)**2, 0),
                  'R3': (q**3*(q+1)*(q*q+1), 0, q*(q*q-1), 1)}
P = pred(p)
for idx, (name, a) in enumerate(orbits.items()):
    t0 = time.time()
    cnt = count_types(a, p, lo=[-1]*6, hi=[1]*6, total_d=-sum(a), shift=1, prec=14)
    ci = int(name[1]) - 1
    line = []
    for r, ty in R.items():
        line.append('%s=%d (pred %d)' % (r, cnt.get(ty, 0), P[r][ci]))
    print('q=%d %s a=%s  %s  [%.1fs]' % (p, name, a, '  '.join(line), time.time()-t0))
    sys.stdout.flush()
