#include <math.h>
#include <stdio.h>

int fnum(int num)
{
    int op=num,sum=0;
    while(num)
    {
        sum+=pow(num%10,4);
        num/=10;
    }
    if(op==sum) return 1;
    return 0;
}
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    for(;n<=m;n++)
    {
        if(fnum(n)) printf("%d ",n);
    }
    return 0;
}