Author: | A. Klenin | Time limit: | 1 sec | |
Input file: | input.txt | Memory limit: | 256 Mb | |
Output file: | output.txt |
Young programmer Vasya works for a local government.
His first job is to automate filling of paper forms. A form is represented by a single string consisting of Latin letters, spaces and underscores ('_', ASCII 95). Substrings of underscores (known as fields) represent blank spaces left for an applicant to fill. Under each field the paper form has a small caption explaining to the applicant what data he should put over those underscores. For example:
My name is ________ nameIn computerized form, captions are represented by a single string of spaces and Latin letters. Every caption is a single word. Number of captions is guaranteed to be equal to the number of fields. However, number of spaces between captions may be arbitrary, so captions are not necessarily located directly under corresponding fields.
You program must, given the representation of a form and a value for each field caption, put corresponding value into every form field.
When filling a field with a value, additional rules must be observed:
First line of input file contains a string representing the form. Second line contains field captions. Third line contains an integer N — number of different captions. Following 2 × N lines contain N pairs of captions and corresponding values. Captions consist of Latin letters only. Values consist of Latin letters and spaces. All captions are different. Note that several fields may have the same caption.
Output file must contain a single line — a form with all fields filled in. It is guaranteed that values for all captions are present in the input. Note that spaces in the form are significant and must be preserved.
All strings have length from 1 to 1000 characters. All fields consist of at least 3 underscores. 0 ≤ N ≤ 100
No. | Input file (input.txt ) |
Output file (output.txt ) |
---|---|---|
1 |
|
|
2 |
|
|