Skip to content
UPEEC

N-Queens

Hard#recursion#backtracking· solved by 0 · time limit 2.0 s

In how many ways can nn queens be placed on an n×nn \times n chessboard so that no two attack each other (same row, column or diagonal)?

Input

A single integer nn.

Output

The number of solutions.

Constraints

1≤n≤111 \le n \le 11

Sample 1

Input

4

Output

2

Sample 2

Input

1

Output

1

Sign in or join free to run and submit your solution.