while true
    n, m = gets.chomp.split.map(&:to_i)
    break if [n, m] == [0, 0]
    map = []
    dice = []
    n.times{map << gets.to_i}
    m.times{dice << gets.to_i}
    pos = 0
    dice.each_with_index{|d, i|
        pos += dice[i]
        if pos >= n - 1
            puts i + 1
            break
        end
        pos += map[pos]
        if pos >= n - 1
            puts i + 1
            break
        end
    }
end 
