import scala.io.StdIn.readLine object Nabeatsu { def divisibleByThree = (_: Int) % 3 == 0 def containsThree(x: Int): Boolean = x match { case x if x > 10 => x % 10 == 3 || containsThree(x / 10) case 3 => true case _ => false } def main(args: Array[String]): Unit = { val arr = readLine().split(" ").map(_.toInt) (arr(0) to arr(1)).filter(v => divisibleByThree(v) || containsThree(v)).foreach(System.out.println) } }