#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  scanf("%lld %lld", &n, &k);
  long long a[k + 1];
  int i;
  long long ans, x, ansmax = 0, y = 0;
  int ind = 1;
  for (i = 1; i <= k; i++) {
    scanf("%lld", &a[i]);
    if (a[i] <= n) {
      x = n % a[i];
      ans = n - x;
      if (ans >= ansmax) {
        ansmax = ans;
        ind = i;
        y = ans / a[i];
      }
    }
  }
  printf("%d %lld\n", ind, y);
  return 0;
}
