#P9765. Alien Calendar Weekday Determination

    ID: 22911 Type: Default 1000ms 256MiB

Alien Calendar Weekday Determination

Alien Calendar Weekday Determination

On an alien planet, a year has \(m\) months, a month has \(d\) days, and a week has \(w\) days. The days of the week are denoted by lowercase letters from a to z. It is known that the first day of the first month of the first year (i.e. \(1\) year \(1\) month \(1\) day) corresponds to weekday a.

Given a date \(k\) year \(j\) month \(i\) day, determine which weekday it corresponds to.

The total number of days passed since \(1\) year \(1\) month \(1\) day is computed as:

\(\text{days} = (k-1) \times (m \times d) + (j-1) \times d + (i-1)\).

The weekday is then the character obtained by adding \((\text{days} \bmod w)\) to the character 'a' (using 0-indexing). For example, if \(\text{days} \bmod w = 0\), the weekday is 'a', if \(\text{days} \bmod w = 1\), the weekday is 'b', and so on.

inputFormat

The input consists of a single line containing six space-separated integers: \(m\), \(d\), \(w\), \(k\), \(j\), \(i\), which represent the number of months in a year, the number of days in a month, the number of days in a week, the target year, the target month, and the target day, respectively.

outputFormat

Output a single lowercase letter indicating the weekday corresponding to the given date.

sample

12 30 7 1 1 1
a