#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std ;
struct coor{
int x, y;
}loc[30];
int b[30],ans,n;
bool cmp(coor a,coor b){
if(a.y==b.y)return a.x<b.x;
return a.y<b.y;
}
int f(int num,int d,int begin,int p){
if(p==1 && d==begin && num!=1) return 1;
if(p==0)
if(loc[d].y == loc[d+1].y) return f(num+1,d+1,begin,1);
else return 0;
if(p==1) return f(num+1,b[d],begin,0);
}
bool check(){
for(int i=1;i<=n;i++)
if( f(1,i,i,1) == 1 )return 1 ;
return 0;
}
void dfs(int x){
if(x==n+1){if(check()==1)ans++;return ;}
if(b[x]==0)
for(int i=x+1;i<=n;i++)
if(b[i]==0){
b[i]=x;b[x]=i;
dfs(x+1);
b[i]=0;b[x]=0;
}
else dfs(x+1);
return ;
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d%d",&loc[i].x,&loc[i].y);
sort(loc+1,loc+1+n,cmp);
dfs(1);
cout<<ans<<endl;
return 0;
}
网友评论