require 'set'

def bfs(start_node, extra = nil)
    return 0 if start_node.is_goal?(extra)
    reached = Set[start_node]
    dist = 1
    queue = [start_node]
    until queue.empty?
        next_queue = Set.new
        until queue.empty?
            node = queue.shift
            node.each_next_node(extra) do |next_node|
                return dist if next_node.is_goal?(extra)
                next if reached.include?(next_node)
                reached << next_node
                next_queue << next_node
            end
        end
        dist += 1
        queue = next_queue.to_a
    end
    return nil
end

n, m, k = gets.split.map(&:to_i)

dark_rooms = Set[*gets.split.map(&:to_i)]
neighbour = {}
(1..n).each do |i|
    neighbour[i] = [-1] + gets.split.map(&:to_i)
end

start_node = 0
dark_rooms.each do |i|
    start_node += (1 << i)
end

class Integer
    def is_goal?(extra)
        self == 0
    end

    def each_next_node(extra)
        n = extra[:n]
        k = extra[:k]
        dark_rooms = extra[:dark_rooms]
        neighbour = extra[:neighbour]
        prev = extra[:prev]

        (1..k).each do |i|
            a = (1..n).select {|j| self[j] == 1}.map {|j| neighbour[j][i]}
            y = 0
            a.each do |j|
                y |= (1 << j) if dark_rooms.include?(j)
            end
            prev[y] ||= [i, self]
            yield y
        end
    end
end

extra = {
    :k => k,
    :n => n,
    :dark_rooms => dark_rooms,
    :neighbour => neighbour,
    :prev => {}
}
p bfs(start_node, extra)

