require 'matrix'
$n, m, *steps = gets.split.map(&:to_i)

reachable = [nil]
mat = (0..$n).map { (0..$n).map { 0 } }
m.times do
    i, j = gets.split.map(&:to_i)
    mat[i][j] = 1
end
mat = Matrix[*mat]
reachable << mat

steps.max.times do
    reachable << reachable[1] * reachable[-1]
end

$trans = steps.map {|i| reachable[i]}

require 'set'
visited = Set.new

def max_min(u, visited, alpha, beta)
    return visited.size if u == $n
    s = visited.dup
    s << u
    $trans.each do |mat|
        x = min_max(u, mat, s, alpha, beta)
        alpha = x if x > alpha
        return beta if alpha >= beta
    end
    alpha
end

def min_max(u, mat, visited, alpha, beta)
    (1..mat.row_size-1).each do |v|
        next if mat[u, v] == 0
        x = max_min(v, visited, alpha, beta)
        beta = x if x < beta
    end
    beta
end

d = max_min(1, Set.new, 0, Float::INFINITY)
puts d == Float::INFINITY ? 'IMPOSSIBLE' : d