# time complexity: O(nlogn)
# space complexity: O(n)
from typing import List


class Solution:
    def arraysIntersection(self, arr1: List[int], arr2: List[int], arr3: List[int]) -> List[int]:
        return sorted(list(set(arr1).intersection(set(arr2).intersection(set(arr3)))))


arr1 = [1, 2, 3, 4, 5]
arr2 = [1, 2, 5, 7, 9]
arr3 = [1, 3, 4, 5, 8]
print(Solution().arraysIntersection(arr1, arr2, arr3))
