c = int(input()) input() ps = sorted(map(int, input().split())) i = 0 j = len(ps) - 1 while i != j: x = ps[i] y = ps[j] s = x * y if s > c: j -= 1 elif s < c: i += 1 else: print(x, y) break