NOTE assume all numbers are different nums1 set int arg for arg in inp

1
2
3
4
5
6
7
8
9
# NOTE: assume all numbers are different
nums1 = set([int(arg) for arg in input().split()])
nums2 = set([int(arg) for arg in input().split()])
result = list(nums1.intersection(nums2))
result.sort()
print(' '.join([str(x) for x in result]))