Help me in solving DIVNUMB problem

My issue

the output of this program should be only one(single digit) value. but the failed test case throws “n” numbers

My code

m=int(input())
n,a,b,c=map(int,input().split())
i=2
d=0
l=[]
z=0
if n >=1 and n <= 1000 and a >=1 and a<=1000 and b >=1 and b<=1000  and c >=1 and c<=1000:
    while ( i <= 100000000):
        if i % a == 0 or i % b ==0 or i % c ==0:
            d=d+1
            l.insert(z,i)
            z+=1
        if d <= n:
            i=i+1
        
        else:
            break
else:
    print("wrong input")
print(l[n-1])

            
        
        

Learning course: Python with Data structures
Problem Link: CodeChef: Practical coding for everyone