#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 10;
const double Pi = acos(-1);
inline int read() {
  int x = 0, f = 1, ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - 48, ch = getchar();
  return x * f;
}
int n;
double dp[N][N / 10];
signed main() {
  n = read();
  dp[0][0] = 1;
  for (register int i = 1; i <= n * 10; ++i)
    for (register int j = 1; j <= n; ++j)
      dp[i][j] += dp[i - 1][j - 1] * (n - j + 1) / n + dp[i - 1][j] * j / n;
  int Case = read();
  while (Case--) {
    double x = read() / 2000.;
    int ans = 0;
    for (register int i = 1; i <= n * 10; ++i)
      if (dp[i][n] > x) {
        printf("%d\n", i);
        break;
      }
  }
  return 0;
}
