cnf.comment('link ships to board')
covered = defaultdict(list)
for ship1 in all_ships:
for xy in just_ship(*ship1):
covered[xy].append(ship1)
for xy in in_bounds:
cells = [f(*s) for s in covered[xy]]
if not cells:
cnf.write_one(-f(*xy))
continue
cnf.write(iff_gen(f(*xy), cells, modeB=any))