#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

template<class T> inline T &amin(T &a, T b) { if (a>b) a=b; return a; }
template<class T> inline T &amax(T &a, T b) { if (a<b) a=b; return a; }
unsigned xor128_x = 123456789, xor128_y = 362436069, xor128_z = 521288629, xor128_w = 88675123;
unsigned xor128() {
	unsigned t = xor128_x ^ (xor128_x << 11);
	xor128_x = xor128_y; xor128_y = xor128_z; xor128_z = xor128_w;
	return xor128_w = xor128_w ^ (xor128_w >> 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<int>(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;
}