#C13135. Reverse Lookup in a Dictionary
Reverse Lookup in a Dictionary
Reverse Lookup in a Dictionary
You are given a dictionary in the form of key-value pairs and a target integer. Your task is to print all keys whose associated value is equal to the target. The keys must be printed in the order they were input, separated by a single space. If no keys match the target, print an empty line.
In formal terms, if the dictionary is (D = {k_1:v_1, k_2:v_2, \ldots, k_N:v_N}) and the target is (T), then you must output all keys (k_i) such that (v_i = T).
inputFormat
The input is read from standard input (stdin) and has the following format:
Line 1: An integer (N) denoting the number of key-value pairs.
Next (N) lines: Each line contains a key (a non-empty string without spaces) and an integer value, separated by a space.
Last line: An integer representing the target value.
outputFormat
Output to standard output (stdout) a single line containing all keys (in the order of input) whose corresponding value is equal to the target. Separate the keys with a single space. If no keys match, output an empty line.## sample
4
a 1
b 2
c 1
d 3
1
a c