#include<bits/stdc++.h>
using namespace std;
const int N = 4;
//g用来记录已放置蛇的位置
int g[N][N];
//四个方位
int dx[]={0,0,1,-1}, dy[] = {1,-1,0,0};
//检查移动是否合法
bool check(int x,int y){
//这里是<N不是<=N!!!
if(x>=0&&x<N&&y>=0&&y<N) return true;
return false;
}
//深度搜索找到每个点可以得到的最大放置情况数
int dfs(int x, int y, int k){
g[x][y] = k;
if(k==16) return 1;
//这里ans只能设置为局部变量,不能设置为全局遍量
//且局部需要初始化为0,否则计算机会赋给其任一数值
int ans = 0;
for(int i = 0; i < N; i++){
int tx = x + dx[i], ty = y + dy[i];
if(!check(tx,ty)||g[tx][ty]!=0) continue;
ans += dfs(tx,ty,k+1);
//为回溯而置0
g[tx][ty]=0;
}
return ans;
}
int main(){
int ans = 0;
for(int i = 0; i < N; i++){
for(int j = 0; j < N; j++){
//初始化g全为0
memset(g,0,sizeof g);
ans += dfs(i,j,1);
}
}
cout<<ans<<endl;
return 0;
}