#include <iostream>
using namespace std;
bool board[15][15];
int n, result = 0;
bool search(int x, int y)
{
for (int i = 0; i < n; i++)
{
if (board[i][y]) return true; // 세로 열 체크
// 왼쪽 (위) 오른쪽(아래) 대각선 체크
if (x - i >= 0 && y - i >= 0 && board[x - i][y - i]) return true; //2사분면
// 왼쪽(아래) 오른쪽(위) 대각선 체크
if (x - i >= 0 && y + i < n && board[x - i][y + i]) return true; //1사분면
}
return false;
}
void solution(int p)
{
if (p == n)
{
result++;
return;
}
for (int y = 0; y < n; y++)
{
if (!board[p][y])
{
if (search(p, y)) continue;
board[p][y] = true;
solution(p + 1);
board[p][y] = false;
}
}
}
int main(void)
{
cin >> n;
solution(0);
cout << result;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmJvb2wgYm9hcmRbMTVdWzE1XTsKaW50IG4sIHJlc3VsdCA9IDA7Cgpib29sIHNlYXJjaChpbnQgeCwgaW50IHkpCnsKCWZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQoJewoJCWlmIChib2FyZFtpXVt5XSkgcmV0dXJuIHRydWU7IC8vIOyEuOuhnCDsl7Qg7LK07YGsCgoJCS8vIOyZvOyqvSAo7JyEKSDsmKTrpbjsqr0o7JWE656YKSDrjIDqsIHshKAg7LK07YGsCgkJaWYgKHggLSBpID49IDAgJiYgeSAtIGkgPj0gMCAmJiBib2FyZFt4IC0gaV1beSAtIGldKSByZXR1cm4gdHJ1ZTsJLy8y7IKs67aE66m0CgoJCS8vIOyZvOyqvSjslYTrnpgpIOyYpOuluOyqvSjsnIQpIOuMgOqwgeyEoCDssrTtgawKCQlpZiAoeCAtIGkgPj0gMCAgJiYgeSArIGkgPCBuICYmIGJvYXJkW3ggLSBpXVt5ICsgaV0pIHJldHVybiB0cnVlOwkvLzHsgqzrtoTrqbQKCX0KCXJldHVybiBmYWxzZTsKfQoKdm9pZCBzb2x1dGlvbihpbnQgcCkKewoJaWYgKHAg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