a,b =[int(x) for x in input().split()]
for x in range(a,b+1):
    c=sum([int(x)**4 for x in str(x)])
    if x==c:
        print(x,end=" ")