#K89277. Intersection of Two Sorted Lists

    ID: 37495 Type: Default 1000ms 256MiB

Intersection of Two Sorted Lists

Intersection of Two Sorted Lists

Given two sorted lists \( A \) and \( B \), your task is to compute their intersection. The intersection is defined as the set of elements that appear in both lists. The lists are given in ascending order, and the resulting intersection must also be in ascending order.

Input/Output Requirements: Your program should read input from stdin and output to stdout. The first input line contains the elements of list \( A \) and the second input line contains the elements of list \( B \), both as space-separated integers.

Example:

Input:
1 3 5 7
3 5 8

Output: 3 5

</p>

If there is no intersection, output an empty line.

inputFormat

The input consists of two lines. The first line contains space-separated integers representing the sorted list A, and the second line contains space-separated integers representing the sorted list B.

outputFormat

Output a single line containing the space-separated common integers from both lists in ascending order. If there is no common element, output an empty line.## sample

1 3 5 7
3 5 8
3 5

</p>