#K76957. 24-hour to 12-hour Time Conversion

    ID: 34757 Type: Default 1000ms 256MiB

24-hour to 12-hour Time Conversion

24-hour to 12-hour Time Conversion

You are given a list of times in 24-hour format. Your task is to convert each time to a 12-hour format with an AM/PM suffix.

Each time is represented as a string of exactly 4 digits (HHMM) where HH represents the hour (00 to 23) and MM represents the minute (00 to 59).

The conversion rules are as follows:

  • If HH is 00, the hour is shown as 12 with an AM suffix.
  • If 01 ≤ HH ≤ 11, keep the same hour with an AM suffix (pad with leading zero if necessary).
  • If HH is 12, the time is listed as is with a PM suffix.
  • If 13 ≤ HH ≤ 23, subtract 12 from the hour and append a PM suffix (pad with leading zero if needed).

The output should display each converted time on a new line.

For instance, converting "0930" should yield "09:30 AM" and "2315" should yield "11:15 PM".

Note: If the time is represented as \(HHMM\), formatting the output should include a colon between the hour and minutes, for example \(\texttt{09:30\ AM}\).

inputFormat

The input is read from stdin and consists of the following:

  1. An integer \(n\) on the first line, representing the number of times.
  2. Following \(n\) lines, each containing a 4-digit string representing time in 24-hour format.

outputFormat

The output should be written to stdout and must contain \(n\) lines. Each line contains the converted time in 12-hour format with an appropriate AM/PM suffix.

## sample
4
0930
2315
0000
1200
09:30 AM

11:15 PM 12:00 AM 12:00 PM

</p>