#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
  out << a.first << " " << a.second;
  return out;
}
template <typename T, typename T1>
T amax(T& a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T& a, T1 b) {
  if (b < a) a = b;
  return a;
}
const long long INF = 1e18;
const int32_t M = 1e9 + 7;
const int32_t MM = 998244353;
const long long N = 1005;
double dp[8 * N][N];
double ans[8 * N];
void solve() {
  long long k, q;
  cin >> k >> q;
  dp[0][0] = 1;
  for (long long i = 1; i < 8 * k + 1; i++) {
    for (long long j = 1; j < k + 1; j++) {
      dp[i][j] = (1.0 * j / k) * dp[i - 1][j] +
                 (1.0 * (k - j + 1) / k) * dp[i - 1][j - 1];
    }
    ans[i] = dp[i][k];
  }
  for (long long i = 0; i < q; i++) {
    long long p;
    cin >> p;
    double tmp = 1.0 * p / 2000;
    long long pr = lower_bound(ans + 1, ans + 1 + 8 * k, tmp) - ans;
    cout << pr << "\n";
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
