n=26
end="22"
def three(number):
threenum=""
while number:
threenum=str(number%3)+threenum
number//=3
return threenum
massiv=[]
for i in range(1,n+1):
if three(i)[-2:] == end:
massiv.append(i)
print(*massiv, sep=",")
n=26
end="22"
def three(number):
threenum=""
while number:
threenum=str(number%3)+threenum
number//=3
return threenum
massiv=[]
for i in range(1,n+1):
if three(i)[-2:] == end:
massiv.append(i)
print(*massiv, sep=",")