Help me in solving COKE problem

My issue

i dont know what is the problem in my code, pls help

My code

#taking inputs
for _ in range(int(input())):
    n , time, amb, l, r = map(int,input().split())
    dict  = {}
    pricel=[]
    for i in range(n):
        temp, price = map(int,input().split())
        dict[price]=temp
        pricel.append(price)
    # done taking inputs
    # adjusting the temp values according to the time taken by the chef to reach home
    for i in range(time):
        for j in range(n):
            if dict[pricel[j]]>amb:
                dict[pricel[j]]-=1
            elif dict[pricel[j]]<amb:
                dict[pricel[j]]+=1
            else:
                continue
    # sorting the dictionary
    keys = list(dict.keys())
    keys.sort()
    sdict = {i: dict[i] for i in keys}
    # telling the price of the coke can within the range l,r
    for i in range(n):
        if sdict[pricel[i]]>=l and sdict[pricel[i]]<=r:
            print(keys[i])
            break
    else:
        print(-1)

Problem Link: COKE Problem - CodeChef