#C6264. Reverse Dictionary Lookup

    ID: 50005 Type: Default 1000ms 256MiB

Reverse Dictionary Lookup

Reverse Dictionary Lookup

You are given a dictionary d of key-value pairs and a target value. Your task is to return and print all keys from the dictionary such that their corresponding values equal the target.

Formally, you need to output the list \( L = \{ k \mid d[k] = t \} \) while preserving the order of input.

If no keys match, output an empty line.

inputFormat

The input is given via stdin in the following format:

  1. An integer n representing the number of key-value pairs in the dictionary.
  2. n lines follow, each containing a key (string without spaces) and an integer value separated by a single space.
  3. A final line containing an integer target.

You can assume that keys do not contain spaces.

outputFormat

Output a single line to stdout with the keys (in their original input order) that have the value equal to the target, separated by a single space. If no keys are found, output an empty line.

## sample
3

a 1
b 2
c 1
1
a c