#include <bits/stdc++.h>
#define ll long long
#define vect vector<int>
using namespace std;
signed main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	vect v1 = {};
	vect v2 = {};
	ll n,q,a,b,x; cin >> n >> q;
	vect v3 = {};
	for(int i = 0; i < n; i++){
		cin >> a;
		v1.push_back(a);
	}
	for(int m = 0; m < q; m++){
		cin >> b;
		v2.push_back(b);
}   
    sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	x = round(v1.size()/2);
	int z = 0;
	while(z<q){
		if (v2[z] == v1[x]){
			v3.push_back(0);
		}
	    if(v2[q] < v1[n] || v2[0] > v1[0]){
			v3.push_back(1);
	    }
		if(v2[q] > v1[n] || v2[0] < v1[0]){
			v3.push_back(v1.size());
			break;
		}
		z++;
	}
	for(int d = 0; d < v3.size(); d++){
          cout << v3[d] << endl;
	}
}