#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t k, n, Max = 0, iMax = 0, t;
  cin >> n >> k;
  vector<int64_t> a(k);
  vector<int64_t> res;
  for (auto &i : a) {
    cin >> i;
  }
  for (auto &i : a) {
    t = (n / i) * i;
    res.push_back(t);
  }
  for (int64_t i = 0; i < k; i++) {
    if (res[i] > Max) {
      Max = res[i];
      iMax = i;
    }
  }
  cout << iMax + 1 << " " << n / a[iMax];
}
