n = gets.to_i
m = 10 ** 9 + 7

pow_2 = Array.new(n+1) {|i| 1 << i}

d = Array.new(pow_2[n], 0)
d[0] = 1
s = [0]

n.times do
    a = gets.split.map(&:to_i)
    t = []

    n.times do |i|
        next if a[i] == 0

        s.each do |e|
            next if e[i] == 1
            x = e | pow_2[i]
            t << x
            d[x] += d[e]
        end
    end

    t.uniq!
    t.each {|e| d[e] %= m}
    s = t
end

p d[-1]
