N, M = gets.split.map(&:to_i)
current_state = 1
rules = Array.new(N) { |i| i = 0 }
actions = Array.new(M) { |i| i = 0 }

N.times do |i|
  rules[i] = gets.to_i
end

M.times do |i|
  actions[i] = gets.to_i
end

actions.each_with_index do |action, i|
  puts "-----------#{i}-------------------------------"
  puts "current_state : #{current_state}"
  puts "action: #{action}"
  current_state += action
  if current_state >= 10
    p i+1
    break
  end
  current_state += rules[current_state-1]
  if current_state >= 10
    p i+1
    break
  end
end