#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb emplace_back
#define pii pair<int , int>
#define F first
#define S second
const int mod = 1000000007;
const int MAXX = 1e6 +5;

int t , n;
string s;
int a[MAXX];

signed main()
{
    _FastIO;
        cin >> n;
        cin >> s;/*
        vector<int> v(n + 2 , 0);

        q[0] = 0;
        int m = 0;
        int p = 0;
        int tp = 0;
        for(int i = 0; i < n; i++){
            if(s[i] == '<')
                m++;
            else{
                m--;
                if(m < p){
                    p = m;
                    tp = i + 1;
                }
            }
            q[i + 1] = m;
        }*/
        for(int i = 0; i <= n; i++){
            cin >> a[i];
        }
        int k = 100000;
        for(int i = 1; i <= n; i++){
            k = min(k , abs(a[i] - a[i - 1]));
        }
        cout << k << endl;
        vector<int> q(n + 2 , 0);
        vector<int> b(n + 2 , 0);
        for(int i = 0; i <= n; i++){
            b[i] = a[i] / (k);
            q[i] = a[i] % k;
        }
        for(int i = 1; i < k; i++){
            for(int j = 0; j <= n; j++){
                if(i <= q[j])
                    cout << b[j] + 1 << " ";
                else
                    cout << b[j] << " ";
            }
            cout << endl;
        }
        for(int i = 0; i <= n; i++){
            cout << b[i] << " ";
        }
        cout << endl;
    return 0;
}

#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("inline")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #define DEBUG

#ifdef DEBUG
#pragma region
#endif

using namespace std;
#define LL long long
#define PII pair<int, int>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define newl '\n'
#ifdef DEBUG
#define debug(...) cerr << '[', _debug(__VA_ARGS__)
#else
#define debug(...)
#endif

const int INF = 1e9;

template <typename T>
void _debug(T a) {
  cerr << a << ']' << endl;
}

template <typename T, typename... Args>
void _debug(T a, Args... args) {
  cerr << a << ", ";
  _debug(args...);
}

#ifdef DEBUG
#pragma endregion
#endif

int n;
array<int, 2> a[100];

void solve() {
  cin >> n;
  rep(i, n) { cin >> a[i][0] >> a[i][1]; }
  rep(i, n) {
    rep(j, n) {
      rep(k, n) {
        debug(a[i][0], a[i][1], a[j][0], a[j][1], a[k][0], a[k][1]);
        if (a[i] == a[j] || a[j] == a[k] || a[i] == a[k]) {
          continue;
        }
        if ((a[i][1] - a[j][1]) * (a[i][0] - (a[k][0])) ==
            (a[i][1] - a[k][1]) * (a[i][0] - (a[j][0]))) {
          cout << "Yes";
          return;
        }
      }
    }
  }
  cout << "No";
}

int main() {
  // freopen("live.in", "r", stdin);
  // freopen("live.out", "w", stdout);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  // cout << fixed << setprecision(7);
  // int n;
  // cin >> n;
  // rep(i, n)
  //     //
  solve();
  cout << flush;
}
