local mod = 1000000007
local bls, brs = bit.lshift, bit.rshift
local n = io.read("*n")
local t = {}
for i = 1, n do
  t[i] = {}
  for j = 1, n do
    t[i][j] = io.read("*n") == 1
  end
end

local tot = bls(1, n)
local alltask = {}
local stagetask = {}
do
  for i = 1, n do
    stagetask[i] = {}
  end
  for i = 1, tot - 1 do
    -- set empty state
    alltask[i] = 0
  end
  for i = 1, tot - 1 do
    local ti = i
    local cnt = 0
    for j = 1, n do
      if ti % 2 == 1 then
        cnt = cnt + 1
        ti = ti - 1
      end
      ti = ti / 2
    end
    table.insert(stagetask[cnt], i)
  end
  -- set first state
  local tmp = 1
  for i = 1, n do
    alltask[tmp] = t[1][i] and 1 or 0
    tmp = tmp * 2
  end
end

for stage = 1, n - 1 do
  local stlen = #stagetask[stage]
  for i_stagetask = 1, stlen do
    local used = stagetask[stage][i_stagetask]
    local mul = 1
    local tmp = used
    for j = 1, n do
      if tmp % 2 == 0 then
        if t[stage + 1][j] then
          alltask[used + mul] = (alltask[used + mul] + alltask[used]) % mod
        end
      else
        tmp = tmp - 1
      end
      tmp = tmp / 2
      mul = mul * 2
    end
  end
end
print(alltask[tot - 1])
