Hide

Problem A
Calendar Conundrum!

The Registrar’s Office has been digging through some ancient student records from the early 20th century, with the goal of finally digitizing some of this information. However, to their surprise, they found that calendar dates were written in three different formats! More specifically:

  • Format #1: month day year

  • Format #2: day month year

  • Format #3: year month day

Where day, month, and year were written as a number between 1 and 99, and each was separated by a single space.

Unfortunately, most records don’t specify what format is being used. In some cases, this doesn’t matter because the format can be easily inferred. For example, given this date:

10 31 16

We can easily tell that this must be October 31, 1916 in Format #1, because the above numbers would not make sense in the other two formats (31 would not be a valid month in either Format #2 or Format #3).

However, some dates can be ambiguous. For example:

2 10 57

The above date could refer to either February 10th, 1957 (in Format #1) or October 2nd, 1957 (in Format #2). Note, however, that the date could not be in Format #3 because the third number is not a valid day.

The Registrar has asked us to write a program that, given a date, will tell us the format of the date or whether the format is ambiguous. Fortunately, the Registrar has already provided us with a set of rules to determine this. Assuming we get three numbers, $a$, $b$, and $c$:

  1. If $a$ is greater than 31, the date is in Format #3.

  2. If $a$ is greater than 12 but less than or equal to 31, then:

    1. If $c$ is greater than 31, the date is in Format #2.

    2. If $c$ is less than or equal to 31, the format is ambiguous.

  3. If $a$ is less than or equal to 12, then:

    1. If $b$ is greater than 12, the date is in Format #1.

    2. If $b$ is less than or equal to 12, the format is ambiguous.

As you may have noticed, their rules don’t account for the fact that some months don’t have 31 days. That is ok: even though the above rules are a bit imprecise, they are nonetheless the rules that the Registrar wants us to follow. You should not try to come up with different or better rules.

Input

The input is composed of a single line, with three integers, $a$, $b$, and $c$, each separated by a single space. You can assume that $1 \leqslant a,b,c \leqslant 99$.

Output

You must print the format of the date: Format #1, Format #2, or Format #3. If the format is ambiguous, print Ambiguous.

Sample Input 1 Sample Output 1
10 31 16
Format #1
Sample Input 2 Sample Output 2
2 10 57
Ambiguous
Sample Input 3 Sample Output 3
57 2 10
Format #3

Please log in to submit a solution to this problem

Log in