for _ in range(int(input())):
    n=int(input())
    x=list(map(int,input().split()))
    m=int(input())
    c=0
    i=0
    a=sum(x)
    if(a>=m):
        while(c<=m):
            c+=x[i]
            if(c>=m):
                break
            i=(i+1)%n
        print(i+1)
    else:
        b=m-a*(m//a)
        if(b==0):
            while(c<=a):
                c+=x[i]
                if(c>=a):
                    break
                i=(i+1)%n
            print(i+1)
        else:
            while(c<=b):
                c+=x[i]
                if(c>=b):
                    break
                i=(i+1)%n
            print(i+1)
