Buggy python submission (verdict: Runtime Error):
for e in iter(input,'0 0'):
 N,M=map(int,e.split())
 S=[int(input())for _ in[0]*N]
 print(S)
 p=b=1
 for i in range(M):
  d=int(input())
  p+=d
  p+=S[~-p]
  print('pos', p)
  if(N<=p)*b:print(-~i);b=0


Fixed submission:
import sys
r=sys.stdin.readline
for e in iter(r,'0 0\n'):
 N,M=map(int,e.split())
 k,p=1,0
 S=[int(r())for _ in[0]*N]
 for d in[int(r())for _ in[0]*M]:
  p+=d;
  if p<N:p+=S[p]
  if N<=p+1:break
  k+=1
 print(k)

Buggy python submission (verdict: Runtime Error):
for e in iter(input,'0 0'):
 N,M=map(int,e.split())
 S=[int(input())for _ in[0]*N]
 print(S)
 p=b=1
 for i in range(M):
  d=int(input())
  p+=d
  p+=S[~-p]
  if(N<=p)*b:print(-~i);b=0


Fixed submission:
import sys
r=sys.stdin.readline
for e in iter(r,'0 0\n'):
 N,M=map(int,e.split())
 k,p=1,0
 S=[int(r())for _ in[0]*N]
 for d in[int(r())for _ in[0]*M]:
  p+=d;
  if p<N:p+=S[p]
  if N<=p+1:break
  k+=1
 print(k)

Buggy python submission (verdict: Runtime Error):
for e in iter(input,'0 0'):
 N,M=map(int,e.split())
 S=[int(input())for _ in[0]*N]
 p=b=1
 for i in range(M):
  d=int(input())
  p+=d
  p+=S[~-p]
  if(N<=p)*b:print(-~i);b=0


Fixed submission:
import sys
r=sys.stdin.readline
for e in iter(r,'0 0\n'):
 N,M=map(int,e.split())
 k,p=1,0
 S=[int(r())for _ in[0]*N]
 for d in[int(r())for _ in[0]*M]:
  p+=d;
  if p<N:p+=S[p]
  if N<=p+1:break
  k+=1
 print(k)

Buggy python submission (verdict: Runtime Error):
for e in iter(input,'0 0'):
 N,M=map(int,e.split())
 k=p=1
 S=[int(input()) for _ in[0]*N]
 for d in[int(input())for _ in[0]*M]:
  p+=n if n-1<=p+i else i+S[p+i]
  if n<=p:break
  k+=1
 print(k)


Fixed submission:
import sys
r=sys.stdin.readline
for e in iter(r,'0 0\n'):
 N,M=map(int,e.split())
 k,p=1,0
 S=[int(r())for _ in[0]*N]
 for d in[int(r())for _ in[0]*M]:
  p+=d;
  if p<N:p+=S[p]
  if N<=p+1:break
  k+=1
 print(k)

Buggy python submission (verdict: Runtime Error):
for e in iter(input,'0 0'):
 N,M=map(int,e.split())
 k,p=1,0
 S=[int(input()) for _ in[0]*N]
 for d in[int(input())for _ in[0]*M]:
  p+=d if N<p+d else d+S[p+d]
  if N<=p+1:break
  k+=1
 print(k)


Fixed submission:
import sys
r=sys.stdin.readline
for e in iter(r,'0 0\n'):
 N,M=map(int,e.split())
 k,p=1,0
 S=[int(r())for _ in[0]*N]
 for d in[int(r())for _ in[0]*M]:
  p+=d;
  if p<N:p+=S[p]
  if N<=p+1:break
  k+=1
 print(k)

Buggy python submission (verdict: Runtime Error):
import sys
r=sys.stdin.readline
def s():
 for e in iter(r,'0 0'):
  N,M=map(int,e.split())
  k,p=1,0
  S=[int(r()) for _ in[0]*N]
  for d in[int(r())for _ in[0]*M]:
   p+=d if N<=p+d else d+S[p+d]
   if N<=p+1:break
   k+=1
  print(k)
if'__main__'==__name__:solve()


Fixed submission:
import sys
r=sys.stdin.readline
for e in iter(r,'0 0\n'):
 N,M=map(int,e.split())
 k,p=1,0
 S=[int(r())for _ in[0]*N]
 for d in[int(r())for _ in[0]*M]:
  p+=d;
  if p<N:p+=S[p]
  if N<=p+1:break
  k+=1
 print(k)

Buggy python submission (verdict: Runtime Error):
import sys
r=sys.stdin.readline
def s():
 for e in iter(r,'0 0'):
  N,M=map(int,e.split())
  k,p=1,0
  S=[int(r()) for _ in[0]*N]
  for d in[int(r())for _ in[0]*M]:
   p+=d if N<=p+d else d+S[p+d]
   if N<=p+1:break
   k+=1
  print(k)
if'__main__'==__name__:s()


Fixed submission:
import sys
r=sys.stdin.readline
for e in iter(r,'0 0\n'):
 N,M=map(int,e.split())
 k,p=1,0
 S=[int(r())for _ in[0]*N]
 for d in[int(r())for _ in[0]*M]:
  p+=d;
  if p<N:p+=S[p]
  if N<=p+1:break
  k+=1
 print(k)

Buggy python submission (verdict: Runtime Error):
def s():
 import sys
 r=sys.stdin.readline
 for e in iter(r,'0 0'):
  N,M=map(int,e.split())
  k,p=1,0
  S=[int(r()) for _ in[0]*N]
  for d in[int(r())for _ in[0]*M]:
   p+=d if N<=p+d else d+S[p+d]
   if N<=p+1:break
   k+=1
  print(k)
if'__main__'==__name__:s()


Fixed submission:
import sys
r=sys.stdin.readline
for e in iter(r,'0 0\n'):
 N,M=map(int,e.split())
 k,p=1,0
 S=[int(r())for _ in[0]*N]
 for d in[int(r())for _ in[0]*M]:
  p+=d;
  if p<N:p+=S[p]
  if N<=p+1:break
  k+=1
 print(k)

Buggy python submission (verdict: Runtime Error):
import sys
r=sys.stdin.readline
for e in iter(r,'0 0\n'):
 N,M=map(int,e.split())
 k,p=1,0
 S=[int(r()) for _ in[0]*N]
 for d in[int(r())for _ in[0]*M]:
  p+=d;
  if N<=p:p+=S[p]
  if N<=p+1:break
  k+=1
 print(k)


Fixed submission:
import sys
r=sys.stdin.readline
for e in iter(r,'0 0\n'):
 N,M=map(int,e.split())
 k,p=1,0
 S=[int(r())for _ in[0]*N]
 for d in[int(r())for _ in[0]*M]:
  p+=d;
  if p<N:p+=S[p]
  if N<=p+1:break
  k+=1
 print(k)