#include <bits/stdc++.h>
using namespace std;
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
typedef pair<ll,ll> P;
#define mod 1000000007

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> a(n+1);
    rep(i,n+1) cin >> a[i];
    
    ll num=10005;
    
    rep(i,n){
        num=min(num,abs(a[i]-a[i+1]));
    }
    
    cout << num << endl;
    
    for(ll i=0;i<num;i++){
        for(ll j=0;j<n+1;j++){
            if(j) cout << " ";
            ll ans=a[j]/num;
            ll amari=a[j]%num;
            if(amari==0){
                cout << ans;
                continue;
            }
            if(i+amari>=num){
                cout << ans+1;
            }else{
                cout << ans;
            }
        }
        cout << endl;
    }

    return 0;
}


















#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define double long double
#define MAX (int) (3*pow(10,5) + 10)
#define pb(a) push_back(a)
using namespace __gnu_pbds;
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = pow(10,9)+7;

 
void deal(){
	ll n;
	cin>>n;
	
	{
		string s;
		cin>>s;
	}
	
	n++;
	
	vector<ll> arr(n,0);
	fori(n){
		cin>>arr[i];
	}
	
	
	ll mn = inf;
	
	
	for(ll i = 1; i<n; i++){
		ll dif = arr[i] - arr[i-1];
		
		if(dif < 0){
			dif = -dif;
		}
		
		mn = min(mn, dif);
	}
	
	
	vector<vector<ll> > val(mn, vector<ll>(n));
	
	fori(mn){
		forj(n){
			ll vl = arr[j] / mn;
			ll extra = arr[j] % mn;
			
			val[i][j] = vl;
			if(i<extra){
				++val[i][j];
			}
		}
	}
	
	cout<<mn<<'\n';
	
	fori(mn){
		forj(n){
			cout<<val[i][j]<<' ';
		}
		cout<<'\n';
	}
	
	
}
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
 
 
 
 