import heapq def kLagestPairs(nums1, nums2, k): ans = [] m, n = len(nums1), len(nums2) k = min(k, m*n) h = [(-(nums1[0]+nums2[0]), 0, 0)] if k > 0 else [] while len(ans) < k: _, i, j = heapq.heappop(h) ans.append(nums1[i]+nums2[j]) if i + 1 < m and j==0: heapq.heappush(h, (-(nums1[i+1] + nums2[j]), i+1, j)) if j + 1 < n: heapq.heappush(h, (-(nums1[i] + nums2[j+1]), i, j+1)) return ans lst=raw_input().strip().split('-') nums1=map(int,lst[0].split(',')) nums2=map(int,lst[1].split(':')[0].split(',')) K=int(lst[1].split(':')[1]) ans=kLagestPairs(sorted(nums1,reverse=True),sorted(nums2,reverse=True),K) print(','.join(map(str,ans)))