#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500005;
long long have, a[MAXN], ans;
int n, anski = 1;
int main() {
  scanf("%I64d %d", &have, &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%I64d", &a[i]);
    if (!a[i]) continue;
    if (have / a[i] * a[i] > ans) ans = have / a[i] * a[i], anski = i;
  }
  printf("%d %I64d\n", anski, have / a[anski]);
  return 0;
}
