Need Help In a Problem

Problem link - Programming Problems and Competitions :: HackerRank

m = []
for i in range(0,N):
    m.append(i+1)
#print(m)
for _ in range(0,Q):
    q = list(map(int,input().split()))
    if len(q) == 3:
        m[q[1]-1] = m[q[1]-1] + q[2]
    if len(q) == 2:
        x = 0
        for i in range(len(m)):
            x = x + m[i]
            if x >= q[1]:
                print(i+1)
                break

This gives wrong answer in a case and timeout in some others. How to approach this?