moviewkn WA but correct in pycharm

Hi!
Can someone maybe point out the mistake(s) in my code, i know it isn’t the most efficient but that’s not the biggest problem since i get WA when i try to submit, i have used other succesful submissions to check my result and i get the same with my code, i don’t think it is a problem with how i return the answer but i am not sure.
Thanks for any help

def themovie():
x = int(input()) # number of tests
for z in range(x):
n = int(input()) # number of movies

    L = list(map(int, input().split())) # movie length

    if len(L) != n: # check movie length arguments
        print("error")
        break

    R = list(map(int, input().split())) # movie rating

    if len(R) != n: # check movie rating arguments
        print("error")
        break

    res = [L[x]*R[x] for x in range(n)] # movie score
    best = max(res) # highest movie score

    if res.count(best) > 1: # check if multiple movies with the highest score
        extra = {}
        for i in range(n):
            if res[i] == best:
                extra["%d" %(R[i])] = i # store the best movies ratings and index
        best = max(extra) # check what movie has the highest rating
        print(extra[best] + 1)
    else:
        print(res.index(best) + 1)

themovie()