#include #include #include #include #include #include using namespace std; typedef long long LL; typedef vector VI; #define REP(i,n) for(int i=0; i inline T &amin(T &a, T b) { if (a>b) a=b; return a; } template inline T &amax(T &a, T b) { if (a> 19) ^ (t ^ (t >> 8)); } void generateA(int N, int A[]) { for(int i = 0; i < N; ++ i) A[i] = xor128() % 100003; } const LL MOD = 100003; LL powMod(LL x, LL y, LL m) { LL r = 1; for (; y; y>>=1) { if (y&1) r = r * x % m; x = x * x % m; } return r; } int N, Q; int A[100111]; int main() { scanf("%d%d", &N, &Q); generateA(N, A); if (N < 1000) { REP ($, Q) { int q; scanf("%d", &q); int ans = 0; REP (i, N) amax(ans, (LL)q * A[i] % MOD); printf("%d\n", ans); } } else { sort(A, A+N); REP ($, Q) { int q; scanf("%d", &q); int ans; if (q == 0) { ans = 0; } else { LL inv_q = powMod(q, MOD-2, MOD); for (ans=MOD-1; ans; ans--) { LL z = ans * inv_q % MOD; int p = lower_bound(A, A+N, z) - A; if (p != N && A[p] == z) { break; } } } printf("%d\n", ans); } } return 0; }