import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Integer c, m;
        Scanner sc = new Scanner(System.in);
        c = sc.nextInt();
        m = sc.nextInt();
        Integer tmp;

        for (int i = 0; i < m; i++) {
            tmp = sc.nextInt();
            if((c%tmp) == 0) {
                if(tmp > c/tmp){
                    System.out.println(c/tmp + " " + tmp);
                    break;
                } else {
                    System.out.println(tmp + " " + c/tmp);
                    break;
                }


            }
        }
    }
}