#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200200;
ll a[maxn], b[maxn], ans[maxn];
ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a%b);
}
int main(void) {
    int n, m; scanf("%d%d", &n, &m);
    for (int i=1; i<=n; i++) scanf("%lld", &a[i]);
    for (int i=1; i<=m; i++) scanf("%lld", &b[i]);
    ll g = 0;
    for (int i=2; i<=n; i++) g = gcd(g, a[i] - a[1]);
    for (int i=1; i<=m; i++) {
        ans[i] = abs(gcd(a[1] + b[i], g));
    }
    for (int i=1; i<=m; i++) printf("%lld%c", ans[i], " \n"[i==m]);
    return 0;
}
