from math import *
pool = int(input())
sizes = int(input())
line = input().strip().split(" ")
line = map(int, line)
line = list(line)
line = sorted(line)

sqp = sqrt(pool)

i = 0
while line[i] < sqp:
    i += 1

lts = line[:i]
gts = line[i:]

for i in lts:
    for j in gts:
        sum = i*j
        if sum > pool:
            break

        if sum == pool:
            print(i, j)

