#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
using pld = pair<ld,ld>;
using vll = vector<ll>;
using vld = vector<ld>;
using vstr = vector<string>;
#define _GLIBCXX_DEBUG
#define rep(j, m) for (ll j = 0; j < (ll)(m); j++)
#define rep2(i, l, n) for (ll i = l; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
const ld PI = 3.1415926535897932;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
vll dx = {-1,0,1,0};
vll dy = {0,-1,0,1};
vll Dx = {-1,-1,-1,0,0,1,1,1};
vll Dy = {-1,0,1,-1,1,-1,0,1};
const ll INF = 1000000000000000;


int main() {
    ll N;
    cin >> N;
    string S;
    cin >> S;
    vll V(N + 1);
    rep(i,N + 1) {cin >> V[i];}
    ll k = INF;
    rep(i,N) {
        k = min(k,abs(V[i + 1] - V[i]));
    }
    cout << k << endl;
    vector<vll> W(k,vll(N + 1));
    rep(i,N + 1) {
        ll a = V[i]/k;
        rep(j,V[i]%k) {
            W[j][i] = a + 1;
        }
        rep2(j,V[i]%k,k) {
            W[j][i] = a;
        }
    }
    rep(i,k) {
        rep(j,N + 1) {
            cout << W[i][j];
            if (j == N) {cout << endl;}
            else {cout << " ";}
        }
    }
}

#include <bits/stdc++.h>
typedef double          D;
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define ff              first
#define ss              second
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define pb              push_back
#define GCD(a, b)       __gcd(a, b)
#define PI              2.0*acos(0.0)
#define pii             pair<int,int>
#define pll             pair<long long,long long>
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define Rep(i,a,b)      for(int i = a; i <= b; i++)
#define rep(i,a,b)      for(int i = a; i >= b; i--)
#define FOR(i,a)        for(int i=0;i<a;i++)
//#pragma                 GCC optimize("Ofast,no-stack-protector")
//#pragma                 GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma                 GCC optimize("unroll-loops")
#define boost           ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

#define si(x)           scanf("%d",&x)
#define pi(x)           printf("%d",x)
#define sss(str)         scanf("%s",str)
#define pl(x)           printf("%lld",x)
#define sl(x)           scanf("%lld",&x)
#define sii(x,y)        scanf("%d %d",&x,&y)
#define sll(x,y)        scanf("%lld %lld",&x,&y)
#define siii(x,y,z)     scanf("%d %d %d",&x,&y,&z)
#define slll(x,y,z)     scanf("%lld %lld %lld",&x,&y,&z)
using namespace std;
int dx[]={0,0,-1,1};
int dy[]={1,-1,0,0};


//--------------------------code starts here---------------------------------------
const int maxn=1e5+5;
LL arr[maxn];
vector<LL> v,v1;
map<LL,LL> mp;

int main()
{
	int t;
	t=1;
    int test=0;
	//si(t);
	while(t--)
	{
        int n,q;
        sii(n,q);
        Rep(i,1,n)
        {
            sl(arr[i]);
        }
        LL x;
        Rep(i,1,q)
        {
            sl(x);
            v.pb(x);
        }

        v1=v;

        sort(arr+1,arr+n+1);
        sort(v.begin(),v.end());
        LL l,r,cnt=0;
        int idx=0;
        Rep(i,1,n)
        {
            if(idx>=v.size())
                break;
            while(mp[v[idx]]!=0 && idx<v.size())
                idx++;
            if(idx>=v.size())
                break;
            if(i==1)
            {
                if(arr[i]!=1)
                {
                    l=1;
                    r=arr[i]-1;
                }
                else
                    continue;
            }
            else
            {
                l=arr[i-1]+1;
                r=arr[i]-1;
            }
            if(l>r)
                continue;
            cnt+=(r-l+1);

            while(l<=r)
            {
                if(v[idx]<=cnt)
                    l=v[idx]+i-1;
                else
                    break;
            
                if(l>r)
                    break;
                if(idx>=v.size())
                    break;
                mp[v[idx]]=l;
                idx++;
            }
        }

        while(idx<v.size())
        {
            while(mp[v[idx]]!=0 && idx<v.size())
                idx++;
            l=v[idx]+n;
            mp[v[idx]]=l;
        }
        for(int i=0;i<v1.size();i++)
        {
            printf("%lld\n",mp[v1[i]]);
        }
	}

	return 0;
}