#include int result; int n; int m[8][8]; bool check(int y) { for (int j = 0; j < y; j++) { int c = 0; for (int i = 0; i < n; i++) { c += m[j][i]; } if (c != 2) return false; } if (y == n) { for (int i = 0; i < n; i++) { int c = 0; for (int j = 0; j < n; j++) { c += m[j][i]; } if (c != 2) return false; } } return true; } void app(int y, int x) { if (x == n) { y++; x = 0; if (!check(y)) return; } if (y == n) { result++; return; } // do it if (y != x) { m[y][x] = 1; app(y, x+1); m[y][x] = 0; } app(y, x+1); } int main(void) { scanf("%d", &n); app(0,0); printf("%d\n", result); return 0; }