object Main extends App {
    val w = Map(
        ('A', '0') -> 'X',
        ('A', '1') -> 'Y',
        ('B', '0') -> 'Y',
        ('B', '1') -> 'X',
        ('W', '0') -> 'B',
        ('W', '1') -> 'Y',
        ('X', '1') -> 'Z',
        ('Y', '0') -> 'X',
        ('Z', '0') -> 'W',
        ('Z', '1') -> 'B')
    for (p <- io.Source.stdin.getLines if p != "#") {
        val x = p.foldLeft('A'){case q => w.get(q) match {
            case None => ' '
            case Some(n) => n
        }}
        if (x == 'B') println("Yes")
        else println("No")
    }
}