暴力啊暴力
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
typedef long long ll;
int main()
{
int P,A;
while(cin>>P>>A)
{ int t=0;
for(ll i=0;i<=P;i++)
{
ll s=i;
s%=P;
s*=s;
s%=P;
if(s==A)
{ if(t==0)
{
printf("%lld",i);t++;
}
else
printf("% lld",i);
}
}
if(t==0)
puts("No Solution");
else
puts("");
}
return 0;
}