#include <bits/stdc++.h>
#ifdef LOCAL
#include "debuger.hpp"
#else
#define DUMP(...) 1145141919810
#define CHECK(...) (__VA_ARGS__)
#endif

using LL = long long;
const int kN = 200000 + 5;
int n, m;
LL a[kN];
LL b[kN];

LL gcd(LL a, LL b) {
  return b == 0 ? a : gcd(b, a % b);
}

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &a[i]);
  }
  for (int i = 0; i < m; ++i) {
    scanf("%lld", &b[i]);
  }
  std::sort(a, a + n);
  LL g = 0;
  for (int i = 0; i + 1 < n; ++i) g = gcd(g, a[i + 1] - a[i]);
  for (int i = 0; i < m; ++i) {
    printf("%lld%c", gcd(a[n - 1] + b[i], g), " \n"[ i + 1 == m]);
  }
}
