#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    string S;
    cin >> S;
    reverse(ALL(S));
    for (auto &x : S) {
        if (x == '6') {
            x = '9';
        } else if (x == '9') {
            x = '6';
        }
    }
    cout << S << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    string s;cin>>s;
    vector<ll> a(n+10),c(n+10,100);
    rep(i,n+1) cin>>a[i];
    ll d=1e9;
    rep(i,n)chmin(d,abs(a[i+1]-a[i]));
    cout<<d<<endl;
    rep(i,d){
        vector<ll> b;
        rep(j,n+1)cout<<(a[j]+i)/d<<" ";
        cout<<endl;
    }
}