#include<iostream> #include<algorithm> using namespace std ; int main() { int n ; cin>>n; int d[n][n]; int u[n]; int mul = 1 ; int sum = 0 ; int k = 0 ; for(int i = 1; i<=n ; i++) for(int j = 1 ; j<=n ; j++) cin>>d[i][j]; for(int i = 1 ; i <= n ; i++ ) u[i] = i ; do{ mul = 1 ; k = 0 ; for(int i = 1; i <= n ; i++) mul*=d[i][u[i]]; for(int i = 1; i <= n ; i++) for(int j = i+1 ; j <= n ; j++) if(u[j]-u[i] < 0) k+=1; if(k%2 == 0) mul = mul ; else mul= mul * -1 ; sum += mul ; }while(next_permutation(u+1,u+1+n)); cout << sum << endl ; return 0 ; }