#include <iostream>
using namespace std;
#define ll long long
int N;
bool d[16]={0};
bool d1[32]={0};
bool d2[32]={0};
ll check(int i, int cnt) {
int x=i/N;
int y=i%N;
ll res=0;
if (cnt<=x-1)
return 0;
if (i>=N*N || cnt==N)
return cnt==N;
if (d[y] || d1[x+y] || d2[x-y+N-1])
return check(i+1, cnt);
d[y] = d1[x+y] = d2[x-y+N-1] = 1;
res += check((x+1)*N, cnt+1);
d[y] = d1[x+y] = d2[x-y+N-1] = 0;
res += check(i+1, cnt);
return res;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> N;
cout << check(0, 0);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojZGVmaW5lIGxsIGxvbmcgbG9uZwoKaW50IE47CmJvb2wgZFsxNl09ezB9Owpib29sIGQxWzMyXT17MH07CmJvb2wgZDJbMzJdPXswfTsKCmxsIGNoZWNrKGludCBpLCBpbnQgY250KSB7CiAgICBpbnQgeD1pL047CiAgICBpbnQgeT1pJU47CiAgICBsbCByZXM9MDsKICAgIAogICAgaWYgKGNudDw9eC0xKQogICAgCXJldHVybiAwOwogICAgaWYgKGk+PU4qTiB8fCBjbnQ9PU4pCiAgICAgICAgcmV0dXJuIGNudD09TjsKICAgIAogICAgaWYgKGRbeV0gfHwgZDFbeCt5XSB8fCBkMlt4LXkrTi0xXSkKICAgICAgICByZXR1cm4gY2hlY2soaSsxLCBjbnQpOwogICAgCiAgICBkW3ldID0gZDFbeCt5XSA9IGQyW3gteStOLTFdID0gMTsKICAgIHJlcyArPSBjaGVjaygoeCsxKSpOLCBjbnQrMSk7CiAgICBkW3ldID0gZDFbeCt5XSA9IGQyW3gteStOLTFdID0gMDsgCiAgICAKICAgIHJlcyArPSBjaGVjayhpKzEsIGNudCk7CiAgICAKICAgIHJldHVybiByZXM7Cn0KCmludCBtYWluKCkgewogICAgY2luLnRpZSgwKS0+c3luY193aXRoX3N0ZGlvKDApOwogICAgY2luID4+IE47CiAgICBjb3V0IDw8IGNoZWNrKDAsIDApOwp9