#include <bits/stdc++.h>
using namespace std;
const double PI = std::atan(1.0) * 4;
int dx[] = {1, 0, 0, -1};
int dy[] = {0, 1, -1, 0};
const long long mod = 1000000000 + 7;
int main() {
  long long n, k;
  scanf("%lld", &n);
  scanf("%lld", &k);
  long long a[k];
  for (int i = 0; i < k; i++) scanf("%lld", &a[i]);
  long long remain = 1e18 + 1;
  long long type, amount;
  for (int i = 0; i < k; i++) {
    long long temp = n - ((n / a[i]) * a[i]);
    if (temp <= remain) {
      remain = temp;
      type = i + 1;
      amount = n / a[i];
    }
  }
  printf("%lld %lld", type, amount);
}
