def func(n,sum = 0): s = str(n) for i in s: sum += int(i) ** 4 if sum == n: return True return False a,b = map(int,input().split()) lst = [] for i in range(a,b + 1): if func(i): lst.append(str(i)) print(' '.join(lst))