#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
vector<int> a(N);
for (int i = 0; i < N; i++) {
cin >> a[i];
}
vector<int> b(K);
for (int i = 0; i < K; i++) {
cin >> b[i];
}
for (int i = 0; i < K; i++) {
int x = b[i];
auto d = lower_bound(a.begin(), a.end(), x);
int h = d - a.begin();
int g = a[h];
if (h > 0 && abs(a[h - 1] - x) <= abs(a[h] - x)) {
g = a[h - 1];
}
cout << g << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBpbnQgTiwgSzsKICAgIGNpbiA+PiBOID4+IEs7CgogICAgdmVjdG9yPGludD4gYShOKTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgTjsgaSsrKSB7CiAgICAgICAgY2luID4+IGFbaV07IAogICAgfQoKICAgIHZlY3RvcjxpbnQ+IGIoSyk7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IEs7IGkrKykgewogICAgICAgIGNpbiA+PiBiW2ldOyAgCiAgICB9CgogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBLOyBpKyspIHsKICAgICAgICBpbnQgeCA9IGJbaV07CiAgICAgICAgYXV0byBkID0gbG93ZXJfYm91bmQoYS5iZWdpbigpLCBhLmVuZCgpLCB4KTsKICAgICAgICBpbnQgaCA9IGQgLSBhLmJlZ2luKCk7CiAgICAgICAgaW50IGcgPSBhW2hdOyAgCiAgICAgICAgaWYgKGggPiAwICYmIGFicyhhW2ggLSAxXSAtIHgpIDw9IGFicyhhW2hdIC0geCkpIHsKICAgICAgICAgICAgZyA9IGFbaCAtIDFdOyAgCiAgICAgICAgfQogICAgICAgIGNvdXQgPDwgZyA8PCBlbmRsOwogICAgfQoKICAgIHJldHVybiAwOwp9Cg==