Problem C - Warning: May Cause Drowsiness

Curez-R-Us pharmacy uses many informational or warning labels on the medications it dispenses, such as "Take with food", and "May cause drowsiness". To keep track of which labels should be used with which medications, Curez-R-Us maintains a text file. Each line of the file is 94 characters long. The first 55 characters of each line contain information about the medication, and the remaining 39 characters hold up to 13 three-lefter codes for the labels that must be affixed when that medication is dispensed. Specifically, the format of a line in this file is as follows:

Characters 1-5 The Curez-R-Us unique 5-character identifier for the medication
Characters 6-25 The brand name for the medication, right-padded with spaces
Characters 26-55 The generic name for the medication, right-padded with spaces
Characters 56-94 Thirteen three-character fields, each containing either three blanks or a three-digit label code. If a medication requires N labels, then the codes for these labels fill the N leftmost label code fields.

No medication currently requires more than thirteen informational or warning labels.

Although Curez-R-Us recently celebrated 27 years of faultless labeling, a database engineer has informed the pharmacy that it should reorganize the way in which its information is stored, and the pharmacy has reluctantly agreed to allow the engineer to modify its file. The engineer says that the information should be stored as follows:

First part of the file [Medications]:
A sequence of 55-character lines, the first 55 characters of each line of the original file.

Second part of the file [What label goes where?]:
A sequence of 8-character lines, each containing a 5-character medication code xxxxx followed by a three-digit label code yyy, whenever yyy specifies a required label for medication xxxxx.

INPUT: A file in the current Piliz-R-Us format.

OUTPUT: A file in the proposed Pillz-R-Us format providing the same information. Within each part of the output file, the lines may be in any order.


Input File

[each line is right-padded with spaces to a length of 94 characters]:
HX87APaxil                 Paroxetine                     132439980
87ECFSustiva               Efavirenz                      980302
54JJMSurega                Placebo - Sugar Pill

Output File

[The first three lines are padded with spaces to a length of 55 characters]:
HX87APaxil                 Paroxetine
87ECFSustiva               Efavirenz
54JJMSurega                Placebo - Sugar Pill

Scanned and beautified by onTy Toom,