//khodaya khodet komak kon
# include <bits/stdc++.h>

/*
// ordered_set 
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
# define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/

using namespace std;

typedef long long                                        ll;
typedef long double                                      ld;
typedef pair <int, int>                                  pii;
typedef pair <pii, int>                                  ppi;
typedef pair <int, pii>                                  pip;
typedef pair <pii, pii>                                  ppp;
typedef pair <ll, ll>                                    pll;

# define A                                               first
# define B                                               second
# define endl                                            '\n'
# define sep                                             ' '
# define all(x)                                          x.begin(), x.end()
# define kill(x)                                         return cout << x << endl, 0
# define SZ(x)                                           int(x.size())
# define lc                                              id << 1
# define rc                                              id << 1 | 1
# define InTheNameOfGod                                  ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);

ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}

const int xn = 1e2 + 10;
const int xm = 1e5 + 10;
const int sq = 320;
const int inf = 1e9 + 10;
const ll INF = 1e9 + 10;
const int mod = 1e9+7;//1e9 + 7;//998244353;
const int base = 257;

int n, num[xn];
string s;
vector <int> vec[10007];

int main(){
	cin >> n;
	cin >> s;
	for (int i = 1; i <= n+1; ++i)	cin >> num[i];
	int mn = 1e9;
	for (int i = 2; i <= n+1; ++i)	mn = min(mn, abs(num[i]-num[i-1]));
	for (int i = 1; i <= n+1; ++i){
		for (int j = 0; j < num[i]%mn; ++j)	vec[j].push_back(num[i]/mn+1);
		for (int j = num[i]%mn; j < mn; ++j)	vec[j].push_back(num[i]/mn);
	}
	cout << mn << '\n';
	for (int i = 0; i < mn; ++i){
		for (int j : vec[i])	cout << j << ' ';
		cout << '\n';
	}
	return 0;
}

/*
5 14 5 5
0 5 9
5 12 10
0 7 7
7 12 8
4 7 10
0 12
0 5
0 7
7 12
0 13

5 30 5 1
0 5 1
5 10 1
10 15 1
15 20 1
20 25 1
0 25
*/

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include<atcoder/all>
using namespace std;
// using namespace atcoder;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    int n;
    string s;
    cin>>n>>s;

    vector<int> a(n+1);
    for(auto&i:a) cin>>i;
    int k  = 1000000;
    rep(i, n){
      chmin(k, (int)abs(a[i+1] - a[i]));
    }
    cout << k << endl;
    rep(i, k) {
      rep(j, n+1) {
        if(j) cout << " ";
        cout << (a[j]+i)/k;
      }
      cout << endl;
    }

}