#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
bool isarmstrongnumber(long long a)
{
long long s=0;int k=1;
while(a>0)
{
s+=pow(a%10,k);
k+=1;
}
if(s==a)
{
return true;
}
else
{
return false;
}
}
int main()
{
long long n,m;
vector<long long> arl;
while(cin>>n>>m)
{
for(long long k=n; k<=m; k++)
{
if(isarmstrongnumber(k)==true)
{
arl.push_back(k);
}
}
for(int k=0; k<arl.size()-1; k++)
{
cout<<arl[k]<<" ";
}
cout<<arl[arl.size()-1]<<endl;
arl.clear();
}
return 0;
}