#include <bits/stdc++.h>
using namespace std;
const int N=1000001;
bool flag[N+1000];
int Next[N+1000];
int a;
int main(){
	int n;
	cin>>a;
	cin>>n;
	for(int i=1;i<=N;i++){
		int up=(int)sqrt(i);
		if(up*up==i&&i>=a){
			flag[i]=true;
			for(int j=i+i;j<=N;j++){
				flag[j]=true;
			}
		}
	}
	int i=N;
	while(i--){
		if(flag[i])Next[i]=i;
		else{
			Next[i]=Next[i+1];
		}
	}
	while(n--){
		int x;
		cin>>x;
		if(flag[x]){
			cout<<"lucky"<<endl;
		}
		else{
			cout<<Next[x]<<endl;
		}
	}
}
#题解#小杨的幸运数