#include using namespace std; vector dx = {1, 0, -1, 0}; vector dy = {0, 1, 0, -1}; int main(){ int K; cin >> K; vector> dp(1 << 16); dp[0][0] = 1; for (int i = 0; i < (1 << 16); i++){ int p = __builtin_popcount(i); for (int j = 0; j < 16; j++){ if ((i >> j & 1) == 0){ int x = j / 4; int y = j % 4; int ds = 0; for (int k = 0; k < 4; k++){ int x2 = x + dx[k]; int y2 = y + dy[k]; if (0 <= x2 && x2 < 4 && 0 <= y2 && y2 < 4){ int id = x2 * 4 + y2; if ((i >> id & 1) == 1){ ds += p; } else { ds -= p; } } } int i2 = i + (1 << j); for (auto P : dp[i]){ dp[i2][P.first + ds] += P.second; } } } } cout << dp[(1 << 16) - 1][K] << endl; }