# -*- coding: utf-8 -*- def world(x): for i in str(x): if i == "3": return True return False a,b = map(int,input().split()) for i in range(a,b+1): if world(i) or i % 3 == 0: print(i) else: pass