for i in range(A,B): s = str(i) if i % 3 == 0: print (i) elif s.count('3'): print (i)