#P6382. Vehicle Road Restriction Checker in MdOI City

    ID: 19598 Type: Default 1000ms 256MiB

Vehicle Road Restriction Checker in MdOI City

Vehicle Road Restriction Checker in MdOI City

In MdOI City, environmental initiatives have led to a system of vehicular road restrictions on weekdays (Monday to Friday). The restriction rules depend on a vehicle’s license plate. The license plate is an 8-character code consisting of:

  • The first 3 characters: uppercase letters that represent the region.
  • The last 5 characters: a mix of uppercase letters and digits, with at least one digit guaranteed.

The tail digit of the license plate is defined as the first digit encountered when reading the plate from right to left.

For MdOI City, local vehicles have license plates whose first 3 letters are exactly MDA. For example, if a car in MdOI has the plate MDA6780P, then its last five characters are 6780P and the tail digit is \(0\).

The road restriction rules are as follows:

  1. For non-local vehicles (i.e. those whose first three characters are not MDA), the car is restricted on all weekdays (Monday to Friday).
  2. For local vehicles, the restriction schedule is determined by the tail digit as per the following table:
Date Monday Tuesday Wednesday Thursday Friday
Restricted tail digit(s) \(1\) and \(9\) \(2\) and \(8\) \(3\) and \(7\) \(4\) and \(6\) \(5\) and \(0\)

Given a license plate number, determine on which weekdays (from Monday to Friday) the vehicle is subject to road restrictions. For non-local vehicles, output all weekdays.

inputFormat

The input consists of a single line containing an 8-character license plate string.

Note: The string will follow the format described above, with the first 3 characters being uppercase letters and the last 5 characters being a mix of uppercase letters and digits (with at least one digit present).

outputFormat

Output a single line. For local vehicles, output the weekday on which the vehicle is restricted. For non-local vehicles, output all weekdays (i.e. "Monday Tuesday Wednesday Thursday Friday") separated by a single space.

sample

MDA6780P
Friday