#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, k, i, c, d, e, g, h;
  cin >> n >> k;
  long long int a[k];
  cin >> a[0];
  c = (n / a[0]) * a[0];
  g = 1;
  h = (n / a[0]);
  for (i = 1; i < k; i++) {
    cin >> a[i];
    if (a[i] <= n) {
      d = (n / a[i]);
      e = (n / a[i]) * a[i];
      if (e > c) {
        g = i + 1;
        h = d;
        c = e;
      }
    }
  }
  cout << g << " " << h << endl;
  return;
}
int main() { solve(); }
