#C13109. Common Indices Finder

    ID: 42611 Type: Default 1000ms 256MiB

Common Indices Finder

Common Indices Finder

You are given two lists of integers. Your task is to find all integers that appear in both lists. For each common integer, output a list of the indices (0-indexed) where this integer appears in the first list. If no common integers exist, output an empty dictionary.

For example, given the first list as [4, 2, 3, 4, 5] and the second list as [5, 4, 7], the answer is {(4: [0, 3]), (5: [4])}.

Note: All formulas are represented in (\LaTeX) format when needed.

inputFormat

Input is provided through standard input. The first line contains an integer (n) denoting the number of elements in the first list. The second line contains (n) space-separated integers representing the first list. The third line contains an integer (m) denoting the number of elements in the second list. The fourth line contains (m) space-separated integers representing the second list.

outputFormat

Output a dictionary in a Python-like format. Each key in the dictionary is a common integer from both lists, and its value is a list of indices (0-indexed) from the first list where the integer appears. If there are no common integers, output {}.## sample

5
4 2 3 4 5
3
5 4 7
{4: [0, 3], 5: [4]}