#include<bits/stdc++.h>
using namespace std;
int n,a,t;
int main()
{
cin>>a>>t;
bool flag = false;
int superluckysub, superlucky, bigsuperlucky, num, ans;
superluckysub = ceil(sqrt(a));
superlucky = superluckysub*superluckysub;
while (t--)
{
cin>>n;
int f = 0;
if (n <= a)
{
if (n == superlucky)
{
cout<<"lucky"<<endl;
}
else
{
cout<<superlucky<<endl;
}
continue;
}
for (int i = ceil(sqrt(n)); ; i++)
{
if (i*i == n || n%superlucky == 0)
{
cout<<"lucky"<<endl;
f = 1;
}
else
{
bigsuperlucky = i*i;
}
break;
}
if (f == 1)
{
continue;
}
int aaa = ceil((1.0*n)/(1.0*superlucky))*superlucky;
if (aaa < n) aaa+=superlucky;
cout<<min(aaa, bigsuperlucky)<<endl;
}
return 0;
}