#include<bits/stdc++.h>
using namespace std;
char love[21][21];int n;
bool ss[21];
unsigned long long cnt;
void dfs(int now){
if(nown){cnt++;return;}
for(int i=1;i<=n;++i){
if(love[now+1][i]'1'&&!ss[i]){
ss[i]=1;
dfs(now+1);
ss[i]=0;
}
}
}
int main(){
cin>>n;
for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j)
cin>>love[i][j];
dfs(0);
cout<<cnt;
return 0;
}