#include <iostream>
using namespace std;

int main() {
    int ge,shi,bai,qian;
    int fan;
    for(int i=1000;i<10000;i++){
        qian=i/1000;
        bai=(i-qian*1000)/100;
        shi=(i-qian*1000-bai*100)/10;
        ge=i%10;
        fan=ge*1000+shi*100+bai*10+qian;
        if(fan==i*9)cout<<i<<endl;
    }
}