#include using namespace std; int a, n; const int N = 1e6 + 10; int b[N]; /* 2 4 1 4 5 9 4 lucky 8 lucky */ int main() { cin >> a >> n; // 找出所有大于等于a的幸运数 // 1、找出所有大于等于a的完全平方数=超级幸运数 // 2、找出所有超级幸运数的倍数=幸运数 for (int i = a; i < N; i++) if (i == sqrt(i) * sqrt(i)) { for (int j = 1; j * i < N; j++) b[i * j] = 1; } while (n--) { int x; cin >> x; if (b[x]) { cout << "lucky" << endl; } else { for (int i = x + 1; i < N; i++) if (b[i]) { cout << i << endl; break; } } } return 0; }