Treadmill

Time limit1sMemory limit128 MB

Problem

The You'reFat treadmill company has decided to enhance its treadmills so that users can run workout programs from an audio program (either online streaming audio or a CD). The program has upbeat music and encouragement from an instructor. Chirps can be inserted into the audio program to signal changes in speed and inclination. For example, when it is time to increase the treadmill speed, the music briefly stops while the treadmill reads the new speed from the chirp, and then the music resumes. The treadmill supports speeds from 0 to 7 miles per hour and inclinations from 0 to 7 degrees.

A program is a sequence of samples. Each sample ranges from 0 (the minimum value) to 9 (the maximum value). There are three samples per second. Each chirp is a sequence of bits. A 0 bit consists of two samples, each of which is 4 or 5. A 1 bit consists of two samples: the first is 0 or 1, and the second is 8 or 9. A chirp begins with the bits "01". The next three bits give the new speed, least significant bit first. These are followed by three bits for the new inclination, again least significant bit first. Note that every chirp includes both speed and inclination, even if one of them does not change. A chirp for a speed of 3 miles per hour and an inclination of 6 degrees looks like this:

Samples5519191945540918
Bits01110011
MeaningStart bitsSpeed: 3 mphInclination: 6 degrees

Input

The input consists of one or more programs. Each program is implicitly numbered starting at 1. The first line contains a single integer n, the number of programs that follow. Each program is a sequence of samples. Every line of a program contains exactly 30 samples, except the last line, which may contain fewer. The end of each program is marked by a sample with the value 10.

Note that:

  • Any value from 0 to 9 may appear as a sample in the background music, but the chirp start sequence "01" (middle, middle, low, high) never occurs in the background music.
  • Chirps consume time.
  • Each workout is less than 60 minutes long.
  • A chirp with speed 0 does not imply the end of the workout.
  • A chirp may be preceded by one or more samples with the value 4 or 5.
  • Chirps do not necessarily begin on a whole-second boundary.
  • Each chirp is well-formed (only proper 0 or 1 bits occur).

Output

For each audio program, first print a line "Program n", where n is the program number. Then print the time, speed, and inclination of each chirp in that audio program. Each chirp produces one line in the form "mm:ss Speed S Inclination I". Both minutes and seconds are printed with a leading zero (from "00" to "59"). The time of a chirp is the time of the first sample of its start bits, ignoring any fractional seconds. Both the speed S and the inclination I are printed as single decimal digits. There is a single space between each item in the output.