#K56022. Common Codebase Dependencies

    ID: 30106 Type: Default 1000ms 256MiB

Common Codebase Dependencies

Common Codebase Dependencies

This problem requires you to find the common dependencies between two codebases. Each codebase is represented as a list of dependency names. Your task is to find the dependencies that appear in both lists, preserving the order in which they appear in the first codebase.

More formally, given two lists, \(A = [a_1, a_2, \dots, a_n]\) and \(B = [b_1, b_2, \dots, b_m]\), output the list \(C\) containing every element \(a_i\) such that \(a_i \in B\), in the same order as \(A\).

Note: The comparison is case-sensitive.

inputFormat

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

  • The first line contains an integer n, representing the number of dependencies in the first codebase.
  • The next n lines each contain a string denoting a dependency.
  • The following line contains an integer m, representing the number of dependencies in the second codebase.
  • The next m lines each contain a string denoting a dependency.

outputFormat

Print to stdout a single line containing the common dependencies separated by a space, in the same order as they appear in the first codebase. If there are no common dependencies, print an empty line.

## sample
4
numpy
pandas
scipy
matplotlib
4
matplotlib
scikit-learn
pandas
numpy
numpy pandas matplotlib

</p>