#include <algorithm>
#include <string>
#include <vector>
#include <iostream>
using namespace std;
float FF(int x)
{
	float a = 0;
	while (x > 0)
	{
		a += 0.9;
		a += 0.1;
		x--;
	}
	return a;
}
int Sserch(vector <int> v, int key) {
	for (int i = 0; i < v.size(); i++)
		if (v[i] == key)return i;
}
bool Find1(vector <int> v,int key)
{
	return binary_search(v.begin(), v.end(),key);
}
void Glasovi()
{
	int pom = 0;
	int n, q;
	cin >> n >> q;
	vector <int> A;
	for (int i = 0; i < n; i++)
	{
		int y;
		cin >> y;
		A.push_back(y);
	}
	vector <int> B;
	for (int i = 0; i < q; i++)
	{
		int y;
		cin >> y;
		B.push_back(y);
	}
	
	
	for (int i = 0; i < q; i++)
	{
		vector <int> tem = A;
		sort(tem.begin(), tem.end());
		int raz = 0;
		if (Find1(tem, B[i])) {
			int x = B[i];
			int cnt = 0;
			int r = 0;
				r = tem.size() / 2;
			while (tem[r] != x)
			{
				

				
				//cout << "R:" << r << endl;
				/*for (int i = 0; i < tem.size(); i++)
				{
					cout << tem[i] << endl;
				} */
				r = tem.size() / 2;
				if (x < tem[r])
					tem.push_back(tem[0]);
				else if (x > tem[r])
					tem.push_back(x+10);
				sort(tem.begin(), tem.end());
				if (tem[r] == x)break;
				cnt++;
				
			}
			cout << cnt << endl;
		}
		else
		{
			int x = B[i];
			
			int cnt = 1;
			tem.push_back(x);
			sort(tem.begin(), tem.end());
			int r = 0;
				r = tem.size() / 2;
				while (tem[r] != x)
				{
					r = tem.size() / 2;
					if (x < tem[r])
						tem.push_back(tem[0]);
					else if (x > tem[r])
						tem.push_back(x + 10);
					sort(tem.begin(), tem.end());
					if (tem[r] == x)break;
					cnt++;
				}
				cout << cnt;
		}
		
	}

}
int main()
{
	Glasovi();
	return 69420;

}