#include <bits/stdc++.h>
using namespace std;
using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
int main() {
  i64 n, k;
  scanf("%lld %lld", &n, &k);
  i64 ans = -1;
  i64 buy = 0;
  i64 number = 0;
  for (int i = 0; i < k; i++) {
    i64 a;
    scanf("%lld", &a);
    i64 now = n / a * a;
    if (now > ans) {
      ans = now;
      buy = i + 1;
      number = n / a;
    }
  }
  printf("%lld %lld", buy, number);
  return 0;
}
