input = -> { gets.split.map(&:to_i) }
N, M = input[]
a = (1..M).map{ input[] }.sort
    
i = 1 
loop.with_index {|_, c|
    max = -1
    max = [max, a.shift[1]].max while a[0] && a[0][0] <= i
    
    if max < 0 
        puts 'Impossible'
        break
    elsif max == N
        puts c+1 
        break
    end 

    i = max + 1 
}