#K62937. Mirrored Clock Validation

    ID: 31642 Type: Default 1000ms 256MiB

Mirrored Clock Validation

Mirrored Clock Validation

You are given a time in the HH:MM format. When the clock is viewed in a mirror, certain digits transform into others according to the following mapping:

  • 0 \(\to\) 0
  • 1 \(\to\) 1
  • 2 \(\to\) 5
  • 5 \(\to\) 2
  • 8 \(\to\) 8

Given a time string \(AB:CD\) (where \(A\) and \(B\) are the digits of the hour and \(C\) and \(D\) are the digits of the minute), its mirror transformation is defined as follows:

[ \text{Mirrored Hour} = \texttt{mapped}(D),\texttt{mapped}(C), \quad \text{Mirrored Minute} = \texttt{mapped}(B),\texttt{mapped}(A) ]

The resulting mirrored time must satisfy the usual time constraints: the hour must be less than 24 and the minute must be less than 60. If the transformation is not possible because one of the digits cannot be mapped, then the time is considered invalid.

Your task is to process multiple test cases and for each input time, print Valid if its mirrored image is a valid time, and Invalid otherwise.

inputFormat

The first line of input contains an integer \(T\) denoting the number of test cases. Each of the following \(T\) lines contains a single string representing the time in the format HH:MM.

outputFormat

For each test case, print a single line containing either Valid or Invalid depending on whether the mirrored time is valid.

## sample
2
20:50
13:31
Valid

Invalid

</p>