#include using namespace std; using ll = long long; using ull = unsigned long long; using PAIR = pair; using PAIRLL = pair; using vi = vector; using vll = vector; using vvi = vector; using vs = vector; #define rep(i,n) for(int i=0;i=0;i--) #define FOR(i,a,b) for(ll i=a;i<=ll(b);i++) #define FORD(i,a,b) for(ll i=a;i>=ll(b);i--) #define FORA(i,I) for(const auto& i:I) //x:コンテナ #define ALL(x) x.begin(),x.end() #define SIZE(x) ll(x.size()) //定数 #define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf #define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf #define MOD 1000000007 //問題による #define F first #define S second //出力(空白区切りで昇順に) #define coutALL(x) for(auto i=x.begin();i!=--x.end();i++)cout<<*i<<" ";cout<<*--x.end()< parents; vector sizeg; int group_cnt,N; UnionFind(int n){ N = n; group_cnt = N; rep(i,N) parents.push_back(i); rep(i,N) sizeg.push_back(1); } int find(int x){ if (x == parents[x]){ return x; } else{ parents[x] = find(parents[x]); return parents[x]; } } void unite(int x,int y){ x = find(x); y = find(y); if (x > y){ swap(x,y); } if (x == y){ return; } sizeg[x] += sizeg[y]; parents[y] = x; group_cnt -= 1; } int size(int x){ return sizeg[find(x)]; } bool same(int x,int y){ return find(x) == find(y); } int groupcount(){ return group_cnt; } }; struct SegTree{ ll DEFAULT = 0; ll func(ll x, ll y){ return x ^ y; } int N,K = 0,N2; vector dat; SegTree(vector ls){ N = ls.size(); while ((N-1) >> K){ K += 1; } //K -= 1; N2 = 1 << K; rep(i,1<<(K+1)){ dat.push_back(DEFAULT); } rep(i,N){ dat[N2+i] = ls[i]; } for (int i=N2-1;i>0;i--){ dat[i] = func(dat[i<<1],dat[i<<1|1]); } } ll leafval(int x){ return dat[x+N2]; } void update(int x,ll y){ int i = x + N2; dat[i] = y; while (i > 0){ i >>= 1; dat[i] = func(dat[i<<1],dat[i<<1|1]); } } ll query(int L,int R){ L += N2; R += N2; ll vL = DEFAULT; ll vR = DEFAULT; while (L < R){ if (L & 1){ vL = func(vL,dat[L]); L += 1; } if (R & 1){ R -= 1; vR = func(dat[R],vR); } L >>= 1; R >>= 1; } return func(vL,vR); } }; int vector_finder(std::vector vec, int number) { auto itr = std::find(vec.begin(), vec.end(), number); size_t index = std::distance( vec.begin(), itr ); if (index != vec.size()) { // 発見できたとき return 1; } else { // 発見できなかったとき return 0; } } vector vector_find_ll(vector vec,ll num){ int N = vec.size(); vector match_num; rep(i,N){ if (vec[i] == num){ match_num.push_back(i); } } return match_num; } ll maxvec(vector vec){ ll ret = -INF64; int N = vec.size(); rep(i,N){ ret = max(ret,vec[i]); } return ret; } ll minvec(vector vec){ ll ret = INF64; int N = vec.size(); rep(i,N){ ret = min(ret,vec[i]); } return ret; } ll sumvec(vector ls){ ll v = 0; int N = ls.size(); rep(i,N){ v += ls[i]; } return v; } vector valuesmap(map mp){ vector ret; for (const auto & [key,value] : mp){ ret.push_back(value); } return ret; } vector keysmap(map mp){ vector ret; for (const auto & [key,value] : mp){ ret.push_back(key); } return ret; } vector set_to_vec(set st){ vector ret; for (const auto & s:st){ ret.push_back(s); } return ret; } vector set_to_vec(set st){ vector ret; for (const auto & s:st){ ret.push_back(s); } return ret; } set vec_to_set(vector vec){ set ret; for (const auto & s:vec){ ret.insert(s); } return ret; } map Counter(vector vec){ map ret; for (const auto & s:vec){ ret[s] += 1; } return ret; } map Counter(vector vec){ map ret; for (const auto & s:vec){ ret[s] += 1; } return ret; } ll bisect_left(vector &vec,ll arg){ //sort済みvecを二分探索 ll ok=0; ll ng=vec.size(); ll mid; while (abs(ng-ok) > 1){ mid = (ok+ng)/2; if (vec[mid] > arg){ ng = mid; } else{ ok = mid; } } return ok; } ll bisect_right(vector &vec,ll arg){ //sort済みvecを二分探索 ll ng=0; ll ok=vec.size(); ll mid; while (abs(ok-ng) > 1){ mid = (ok+ng)/2; if (vec[mid] > arg){ ok = mid; } else{ ng = mid; } } return ok; } set primeset(ll N){ // N以下の素数を全部列挙 vector lsx(N+1,1); FOR(i,2,ceil(pow(N,0.5)+1)){ if (lsx[i] == 1){ for(ll j=i;j ret; for (ll i=2;i < N+1; i++){ if (lsx[i] == 1){ ret.insert(i); } } return ret; } ll gcd(ll a,ll b){ while (b != 0){ a,b = b,a%b; } return a; } ll lmc(ll a, ll b){ ll c = gcd(a,b); return a*b/c; } ll gcdvec(vector vec){ ll ret=vec[0]; for (const auto & v:vec){ ret = gcd(ret,v); } return ret; } ll lmcvec(vector vec){ ll ret=vec[0]; for (const auto & v:vec){ ret = lmc(ret,v); } return ret; } vector> factorization(ll N){ vector> ret; ll temp = N; FOR(i,2,ceil(pow(N,0.5)+1)){ if (temp%i==0){ ll cnt = 0; while(temp%i==0){ cnt += 1; temp /= i; } ret.push_back({i,cnt}); } } if (temp!=1){ ret.push_back({temp,1}); } if (ll(ret.size())==0){ ret.push_back({N,1}); } return ret; } set factorizationset(ll N){ set ret; if (N==1){ return ret; } ll temp = N; FOR(i,2,ceil(pow(N,0.5)+1)){ if (temp%i==0){ ll cnt = 0; while(temp%i==0){ cnt += 1; temp /= i; } ret.insert(i); } } if (temp!=1){ ret.insert(temp); } return ret; } ll divisorsnum(ll N){//約数の個数 if (N==1){ return 1; } vector> p = factorization(N); ll ret = 1; for (const auto & v:p){ ret *= v[1]+1; } return ret; } vector make_divisors(ll N){ vector lower_divisors , upper_divisors; ll i = 1; while (i*i <= N){ if (N%i==0){ lower_divisors.push_back(i); if (i != (N/i)){ upper_divisors.push_back(N/i); } } i++; } for (ll i=ll(upper_divisors.size())-1 ; i >= 0; i--){ lower_divisors.push_back(upper_divisors[i]); } return lower_divisors; } ll invmod(ll a,ll mod){ if (a==0){ return 0; } if (a==1){ return 1; } return (mod*mod - invmod(mod % a,mod)*(mod/a))%mod; } ll cmbmod(ll n, ll r,ll mod){ if (n < r) return 0; vector inv = {0,1}; for (ll i=2 ; i <= min(r,n-r); i++){ inv.push_back((-inv[mod % i] * (mod / i)) % mod); } ll cmd = 1; for (ll i=1 ; i <= min(r,n-r); i++){ cmd = (cmd*(n-i+1)+inv[i])%mod; } return cmd; } ll permmod(ll n,ll r,ll mod){ ll perm = 1; for (ll i=n;i>=n-r;i--){ perm = (perm*i)%mod; } return perm; } ll modPow(ll a,ll n,ll mod){ if (n==0) return 1; if (n==1) return a%mod; if (n%2==1){ return (a*modPow(a,n-1,mod)) % mod; } ll t = modPow(a,n/2,mod); return (t*t)%mod; } vector invmodls(ll n,ll mod){ vector inv = {0,1}; for (ll i=2 ; i <= n;i++){ inv.push_back((-inv[mod % i] * (mod / i)) % mod); } return inv; } struct NCK{ ll mod; ll N; vector factmod, inv, invfact; NCK(ll N,ll mod){ factmod = {1,1}; for (ll i=2;i<=N;i++){ factmod.push_back((factmod[-1]*i)%mod); } inv = {0,1}; for (ll i=2;i<=N;i++){ inv.push_back((-inv[mod % i] * (mod / i)) % mod); } invfact = {1,1}; for (ll i=2;i<=N;i++){ invfact.push_back((invfact[-1]*inv[i])%mod); } } ll nCk(ll a,ll b){ if (a < b) return 0; return ((factmod[a]*invfact[b]%mod)*invfact[a-b])%mod; } ll invnCk(ll a,ll b){ return ((factmod[a-b]*invfact[a]%mod)*factmod[b])%mod; } }; vector>> factorization_all_n(ll n){//以下の自然数すべてをを素因数分解 vector>> lspn(n+1); vector lsnum(n+1); rep(i,n+1) lsnum[i] = i; vector lsp = set_to_vec(primeset(n)); sort(lsp.begin(),lsp.end()); for (const auto & p:lsp){ for (ll j=1;j cmbmodls(ll n,ll mod){//二項係数逆元使えないver vector lsans={1}; vector lsp = set_to_vec(primeset(n)); sort(lsp.begin(),lsp.end()); vector invp(n+1,0); vector lspmod; vector lsX(ll(lsp.size()),0); rep(i,ll(lsp.size())){ invp[lsp[i]] = i; lspmod.push_back(lsp[i]%mod); } }*/ int main(){ ll A,B; cin >> A >> B; vector ans; for (ll i=A;i<=B;i++){ if (i % 3==0){ ans.push_back(i); } else{ string s = to_string(i); if (cnt_string_char(s,0,s.size(),'3')>0){ ans.push_back(i); } } } for (const auto & i:ans){ cout << i << endl; } }