#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
#include <cassert>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) ((m).find((a)) != m.end())
#define CONTAINS_SET(m, a) ((m).find((a)) != m.end())
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; exit(0); }
void Yes() { cout << "Yes" << endl; exit(0); }
void No() { cout << "No" << endl; exit(0); }


int N;
string S;
int A[110];
int _m[110];

signed main()
{
	cin >> N;
	cin >> S;
	REP(i, N + 1) cin >> A[i];

	int k = INT_MAX;
	for (int i = 0; i < N; i++)
	{
		int diff = abs(A[i] - A[i + 1]);
		k = min(diff, k);
	}

	for (int i = 0; i < N + 1; i++)
	{
		_m[i] = A[i] % k;
	}


	cout << k << endl;
	for (int i = 0; i < k; i++)
	{
		for (int i = 0; i < N + 1; i++)
		{
			int m = _m[i] > 0 ? 1 : 0;
			cout << A[i] / k + m << " ";
			_m[i]--;
		}
		cout << endl;
	}
}



/*
  author: Kamal Kant Bhardwaj
  date:
*/
#include<bits/stdc++.h>
using namespace std;

#define N               3005
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(newx)      __builtin_popcountll(newx)
#define zrobits(newx)      __builtin_ctzll(newx)
#define mod             1000000007
#define inf             1e18
#define ps(newx,y)         finewxed<<setprecision(y)<<newx
#define mk(arr,n,type)  type *arr=new type[n];
#define w(newx)            int newx; cin>>newx; while(newx--)


void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
int mat[10005][103];
int32_t main()
{
  c_p_c();
  int n; cin >> n; string s; cin >> s;
  int a[103];
  for (int i = 0; i <= n; i++)
    cin >> a[i];
  int maxi = mod;
  for (int i = 1; i <= n; i++)
  {
    maxi = min(maxi, abs(a[i] - a[i - 1]));
  }

  int sum = 0;
  for (int i = 0; i < 10005; i++)
    for (int j = 0; j < 103; j++)
      mat[i][j] = 0;
  int div = a[0] / maxi;
  int rem = a[0] % maxi;
  for (int j = 0; j < maxi; j++)
  {
    mat[j][0] = div ;
    if (rem > 0)
    {
      mat[j][0] += 1;
    }
    rem--;
    sum += mat[j][0];
  }
  for (int i = 1; i <= n; i++)
  {

    // int newsum = 0;

    //  int diff = abs(a[i] - sum);
    int div = a[i] / maxi;
    int rem = a[i] % maxi;
    // cout << div << "  " << rem << endl;
    for (int j = 0; j < maxi; j++)
    {
      mat[j][i] = div;
      if (rem > 0)
        mat[j][i] += 1;
      rem--;
    }
  }
  cout << maxi << endl;
  for (int j = 0; j < maxi; j++)
  {
    for (int i = 0; i <= n; i++)
    {
      cout << mat[j][i] << " ";
    }
    cout << endl;

  }


  return 0;

}