import math
combination = 2
num = [4, 8]
limit = 500
print("List of combinations of 4 and 8 upto 500:");
#iterate from 1 to limit
for i in range(1, limit+1):
copyNum = i
count = 0
flag = 0
#check each digit starting from last digit
while(copyNum != 0):
count += 1
lastDigit = copyNum % 10
for j in range(0, combination):
if(num[j] == lastDigit):
flag += 1
copyNum = math.floor(copyNum / 10)
if(count == flag):
print(i, end=" ")