#P1512. Adam's Date Game

    ID: 14798 Type: Default 1000ms 256MiB

Adam's Date Game

Adam's Date Game

Adam and Eve play a game with calendar dates. They start by choosing an arbitrary date from \(1900.1.1\) to \(2006.11.3\) (inclusive). Then they take turns modifying the current date. Adam moves first. In each turn a player may choose one of the following two moves:

  1. Add one day. For example, \(1900.1.1\) becomes \(1900.1.2\). When increasing the day, if the new day exceeds the number of days in that month, the date is changed to the 1st day of the next month (with proper handling of year change when the month exceeds 12).
  2. Add one month. For example, \(1900.1.1\) becomes \(1900.2.1\). However, if the day number of the current date does not exist in the next month (for instance, \(1900.1.31\) would become \(1900.2.31\) but February never has 31 days), such a move is illegal.

All moves must obey the Gregorian calendar rules including leap year considerations. The unique winning move is to change the date exactly to \(2006.11.4\). Note that if a move results in a date beyond \(2006.11.4\) it does not count as a win and is not allowed in a winning strategy. Given the starting date (which is guaranteed to be between \(1900.1.1\) and \(2006.11.3\)), determine whether Adam has a forced winning strategy if both players play optimally.

For example, from 2006 11 3, Adam can add one day to reach \(2006.11.4\) and win immediately.

inputFormat

The input consists of a single line containing three integers separated by spaces: year month day. The date is guaranteed to satisfy \(1900.1.1 \leq \text{date} \leq 2006.11.3\).

outputFormat

Output a single line: Yes if Adam has a winning strategy, or No otherwise.

sample

2006 11 3
Yes