Fix N_Queens

Thanks to Boris Egorov.