#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const long long INF = 1LL << 62;
const int inf = 1 << 30;
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& V) {
  int N = V.size();
  for (int i = 0; i < (N); i++) {
    os << V[i];
    if (i != N - 1) os << " ";
  }
  os << "\n";
  return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> const& P) {
  os << P.first;
  os << " ";
  os << P.second;
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& S) {
  auto it = S.begin();
  while (it != S.end()) {
    os << *it;
    os << " ";
    it++;
  }
  os << "\n";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T>& q) {
  for (auto it = q.begin(); it < q.end(); it++) {
    os << *it;
    os << " ";
  }
  os << endl;
  return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, map<T, S> const& M) {
  for (auto e : M) {
    os << e;
  }
  os << endl;
  return os;
}
vector<pair<int, int>> dxdy = {make_pair(0, 1), make_pair(1, 0),
                               make_pair(-1, 0), make_pair(0, -1)};
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long N, K;
  cin >> N >> K;
  vector<long long> A(K);
  for (int i = 0; i < (K); i++) cin >> A[i];
  long long val = 0;
  pair<long long, long long> ans = {1, 0};
  for (int i = 0; i < (K); i++) {
    long long a = A[i];
    if (val < N / a * a) ans = make_pair(i + 1, N / a), val = N / a * a;
  }
  cout << ans << endl;
}
