A,B=map(int,input().split()) for n in (A,B+1): if n%3==0: print(n) if "3" in str(n): print(n)