/*
  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;

}
#include <bits/stdc++.h>

using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

class rep {
    struct Iter {
        usize itr;
        constexpr Iter(const usize pos) noexcept : itr(pos) {}
        constexpr void operator++() noexcept { ++itr; }
        constexpr bool operator!=(const Iter& other) const noexcept {
            return itr != other.itr;
        }
        constexpr usize operator*() const noexcept { return itr; }
    };
    const Iter first, last;

  public:
    explicit constexpr rep(const usize first, const usize last) noexcept
        : first(first), last(std::max(first, last)) {}
    constexpr Iter begin() const noexcept { return first; }
    constexpr Iter end() const noexcept { return last; }
};

template <class T, T Div = 2>
constexpr T INFTY = std::numeric_limits<T>::max() / Div;

template <class T> bool setmin(T& lhs, const T& rhs) {
    if (lhs > rhs) {
        lhs = rhs;
        return true;
    }
    return false;
}

template <class T> using Vec = std::vector<T>;

void A_main() {
    usize N;
    std::cin >> N;
    Vec<char> S(N);
    for (auto& x : S) {
        std::cin >> x;
    }
    Vec<u32> A(N + 1);
    for (auto& x : A) {
        std::cin >> x;
    }
    u32 min = INFTY<u32>;
    for (const auto i : rep(0, N)) {
        setmin(min, (A[i] < A[i + 1] ? A[i + 1] - A[i] : A[i] - A[i + 1]));
    }
    std::cout << min << '\n';
    for (const auto k : rep(0, min)) {
        for (const auto i : rep(0, N + 1)) {
            std::cout << A[i] / min + (k < (A[i] % min)) << " \n"[i == N];
        }
    }
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    A_main();
    return 0;
}
