#include
#include<bits/stdc++.h>
using namespace std;
int pan(int num){
int d=0,s=0,r,n;
n=num;
// cout<<num;
while(num>0){
num=num/10;++d;
}
num=n;
while(n>0){
r=num%10;
s=s+pow(r,d);
num=num/10;
}
if(s==n){num=n;
return num;}
return 0;
}
int main() {
int a,b;cin>>a>>b;
for(int i=a;i<=b;i++){
int num;
num=i;
// while()
pan(num);
}
return 0;
}