Problem: queens

Problem IDqueens
Difficulty level (0..10)6
Maximum runtime4 minutes
Original problem
Seen at

Queens is a generalization of 8 queens problem. Given N queens in a NxN checker, find the number of all possible positions of the queens in the checker, so that no more than one queen can be found in any row, column and diagonal. Solutions coming from rotation and/or mirroring of other solutions should not be counted (that is count all the solution classes, not all solutions).

Input contains non negative integers below 14. Output should contain the number of solution classes, one at a line.

Sample input:

8
4

Sample output:

23
1