#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;
}
