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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, (T)x); }
template<class T, class U, typename... W> void init(vector<T> &v, U x, size_t n, W... m) { v=vector<T>(n);  for(auto& a : v) init(a, x, m...); }

template <class T>
class SegmentTree{
    struct node{
        int l, r;
        T x;
    };
    unsigned int sz;
    vector<node> a;
    // --- modify this for different operations ---
    T zero = 0;
    void merge(int to, int from1, int from2){
        a[to].l = a[from1].l;
        a[to].r = a[from2].r;
        a[to].x = a[from1].x ^ a[from2].x;
    }
    // ---
public:
    SegmentTree<T>(vector<T>& a){
        sz = 1;
        while(sz < a.size()) sz <<= 1;
        this->a.resize(2*sz);
        for(int i = sz; i<2*sz; i++){
            if (i-sz < a.size())
                this->a[i].x = a[i - sz];
            else
                this->a[i].x = zero;
            this->a[i].l = this->a[i].r = i - sz;
        }
        for(int i = sz-1; i>0; i--)
            merge(i, 2*i, 2*i+1);
    }
    inline int mid(int l, int r){ return l+(r-l)/2;}
    void upd(int pos, int l, int r, int dx){
        if (r < a[pos].l || a[pos].r < l) return;
        if (a[pos].l == a[pos].r && a[pos].l == l) {
            a[pos].x ^= dx;
            return;
        }
        upd(2*pos, l, r, dx);
        upd(2*pos+1, l, r, dx);
        merge(pos, 2*pos, 2*pos+1);
    }
    void upd(int l, int r, int dx){
        upd(1, l, r, dx);
    }
    void upd(int i, int dx){
        upd(i, i, dx);
    }
    T get(int pos, int l, int r){
        if (r < a[pos].l || a[pos].r < l) return zero;
        if (l <= a[pos].l && a[pos].r <= r)
            return a[pos].x;
        int m = mid(a[pos].l, a[pos].r);
        int x1 = get(2*pos, l, r);
        int x2 = get(2*pos+1, l, r);
        return x1 ^ x2;
    }
    T get(int l, int r){
        return get(1, l, r);
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n, q;
    cin >> n >> q;
    vector<int> a(n+1);
    FOR1(i, n) cin >> a[i];

    SegmentTree<int> st(a);

//    FOR1(x, n)
//        cout << st.get(1, x) << endl;
//    return 0;

    FOR(i, q){
        int t, x, y;
        cin >> t >> x >> y;
        if (t == 1){
            st.upd(x, y);
        }
        else{
            int ans = st.get(x, y);
            cout << ans << '\n';
        }
    }

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    vint a(n + 1);
    rep(i,n+1) cin >> a[i];
    int k = inf;
    rep(i,n) k = min(k, abs(a[i + 1] - a[i]));
    vvint b(k, vint(n + 1));
    rep(i,n+1) {
        rep(j,k) b[j][i] = a[i] / k;
        for (int j = k - a[i] % k; j < k; j++) b[j][i]++;
    }
    cout << k << endl;
    rep(i,k) {
        rep(j,n+1) printf("%d%s", b[i][j], j != n ? " " : "\n");
    }
}