#K44067. Invitation Generator

    ID: 27449 Type: Default 1000ms 256MiB

Invitation Generator

Invitation Generator

You are given an invitation template and a set of detail entries. The invitation template is a string that contains placeholders in the form {key}. The details are provided as key-value pairs. For each key in the details, you should replace occurrences of the placeholder {key} in the template with its corresponding value. In addition, if the detail with key RSVP exists and its value is True, then append the text Please RSVP. at the end of the invitation.

Note: The placeholders that are not provided in the details should remain unchanged in the final output.

Example:

Input:
Hi {name}, you are invited to a party on {date} at {venue}. It starts at {time}.
5
name
Alice
date
12th October
time
7 PM
venue
Wonderland
RSVP
True

Output: Hi Alice, you are invited to a party on 12th October at Wonderland. It starts at 7 PM. Please RSVP.

</p>

inputFormat

The input is read from standard input and has the following format:

  1. The first line contains the invitation template as a string. This template can contain one or more placeholders in the format {key}.
  2. The second line contains an integer n, which is the number of detail entries.
  3. The following 2*n lines each describe a key-value pair. For every detail, the first line is the key name and the next line is its corresponding value. For the RSVP key, the value will be either True or False.

outputFormat

The output (printed to standard output) should be the final invitation message after performing the placeholder substitutions. If the detail entry for RSVP is present and its value is True, you must append Please RSVP. to the resulting message.

## sample
Hi {name}, you are invited to a party on {date} at {venue}. It starts at {time}.
5
name
Alice
date
12th October
time
7 PM
venue
Wonderland
RSVP
True
Hi Alice, you are invited to a party on 12th October at Wonderland. It starts at 7 PM. Please RSVP.