#include <bits/stdc++.h>
using namespace std;
const int N = 10010;
const int K = 1010;
double t[K][N];
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  int k, q;
  cin >> k >> q;
  double kk = (double)k;
  t[0][0] = 1;
  for (int n = 1; n < N; ++n) {
    for (int m = 1; m <= k; ++m) {
      t[m][n] = t[m - 1][n - 1] * (k - m + 1) / kk + t[m][n - 1] * m / kk;
    }
  }
  for (int i = 0; i < q; i++) {
    double test;
    cin >> test;
    for (int j = 0; j < N; ++j) {
      if (t[k][j] * 2000 > test - 1e-7) {
        cout << j << endl;
        break;
      }
    }
  }
  return 0;
}
