program necklacemn;
const maxset=70001; maxn=17; yu=1000000007;
var
min,wxz,f:array[0..maxset] of int64;
a,d:array[0..maxn] of longint;
unable:int64; son,s,i,j,l,tot,n:longint;
c:array[0..maxn,0..maxn] of longint;
begin
assign(input,'necklacemn.in'); reset(input);
assign(output,'necklacemn.out'); rewrite(output);
readln(n);
for i:=1 to n do
for j:=1 to n do read(c[i,j]);
for i:=1 to n do d[i]:=1 shl (i-1);
s:=1 shl n-1;
for i:=0 to s do
begin
tot:=0; min[i]:=maxlongint;
for j:=1 to n do
if i and d[j]=d[j] then
begin
if min[i]>d[j] then min[i]:=d[j];
inc(tot); a[tot]:=j;
end;
wxz[i]:=1;
for j:=1 to tot do
for l:=j to tot do
wxz[i]:=wxz[i]*(c[a[j],a[l]]+1) mod yu;
end;
for i:=0 to s do
begin
son:=i and (i-1);
unable:=0;
while son<>0 do
begin
if son and min[i]=min[i] then
unable:=(unable+f[son]*wxz[i-son]) mod yu;
son:=i and (son-1);
end;
f[i]:=((wxz[i]-unable) mod yu+yu) mod yu;
end;
writeln(f[s] mod yu);
close(input); close(output);
end.