Help me in solving SEQSEARCH problem

My issue

In test case’ it is showing 'time limit exceeded

My code

# cook your dish here
for i in range(int(input())):
    x1=0
    x2,x3,k=list(map(int,input().split()))
    lis=[x1,x2,x3]
    count=0
    while count<=k+5:
        lis.append(lis[-1]+lis[-2]-lis[-3])
        count+=1
    a=sorted(lis)
    print(a[k-1])
        
        
        

Problem Link: Sequence Search Practice Coding Problem