#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    
    for(int i = a;i <= b;i++){
        if(i%3 == 0){
            cout << i << endl;
            continue;
        }
        
        for(int j = 1;j < 1000000000;j*=10){
            if((i/j)%10 == 3)cout << i << endl;
        }
        
    }
    
    return 0;
}