using namespace std;

#include <iostream>

int main() {
    int c, m;
    cin >> c >> m;
    int tmp;
    for (int i = 0; i < m; ++i) {
        cin >> tmp;
        if((c%tmp) == 0) {
            if(tmp > c/tmp){
                cout << c/tmp << " " << tmp << endl;
            } else {
                cout << tmp << " " << c/tmp << endl;
            }
            break;
        }
    }


    return 0;
}