#include   <bits/stdc++.h>
#include   <ext/pb_ds/assoc_container.hpp>
#include   <stdio.h>
#include   <stdlib.h>
#include   <iomanip>
#define    FAST       ios::sync_with_stdio(0);cin.tie(0);
#define    pb         push_back
#define    mp         make_pair
#define    ff         first
#define    ss         second
#define    el         "\n"
#define    ll         long long
#define    ld         long double
#define    pii        pair<ii,ii>
#define    pll        pair<ll,ll>
#define    vcii       vector<ii>
#define    vcll       vector<ll>
#define    vcd        vector<double>
#define    vcs        vector<string>
#define    vpii       vector<pii>
#define    vpll       vector<pll>
#define    stl_sort(v)   sort(v.begin(),v.end())
#define    stl_rev(v)    reverse(v.begin(),v.end())
#define    rep(i,x,y) for(ll i=x;i<y;i++)
#define    scll(x)    scanf("%lld",&x)
#define    pfll(x)    printf("%lld",x)
#define    scd(x)     scanf("%llf",&x)
#define    pfd(x)     prinf("%0.5llf\n",x)
using namespace std;

ll bigmod(ll a,ll b,ll m)
{
	if(b==0)return 1%m;
	ll x=bigmod(a,b/2,m);
	x=(x*x)%m;
	if(b%2==1)x=(x*a)%m;

	return x;
}

int main()
{
    /* freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); */

  //FAST

    ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,sum1,sum2;
    ld A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,SUM1,SUM2;

      cin>>n>>m;
		cout<<((bigmod(10,n,m*m)-bigmod(10,n,m))/m)%m<<el;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

long long get_value(vector<long long>& A, long long x) {
    long long ans = x;
    auto first = A.begin();
    auto last = upper_bound(A.begin(), A.end(), x);
    x -= (last - first);
    return x;
}

long long solve(vector<long long>& A, long long kth) {
    long long left = 1;
    long long right = 1;
    if (get_value(A, left) >= kth) {
        return left;
    }
    while (get_value(A, right) < kth) {
        right <<= 1;
    }
    while (right - left > 1) {
        long long mid = (left  + right) / 2;
        if (get_value(A, mid) >= kth) {
            right = mid;
        } else {
            left = mid;
        }
    }
    return right;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, q;
    vector<long long> A;
    cin >> n >> q;
    A.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    while (q--) {
        long long k;
        cin >> k;
        cout <<  solve(A, k) << endl;
    }
    return 0;
}
