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

int main() {
  int M;
  cin >> M >> M;
  vector<string> s(M);
  map<string, int> m;
  set<string> S;
  vector<vector<char>> a(20, vector<char>(20, 'A'));
  deque<tuple<int, int, string>> t;
  for (int i = 0; i < M; i++) {
    cin >> s.at(i);
    if (m.count(s.at(i))) {
      m.at(s.at(i))++;
    }
    else {
      m[s.at(i)] = 1;
    }
  }
  for (int i = 0; i < M; i++) {
    if (!(S.count(s.at(i)))) {
      S.insert(s.at(i));
      t.push_back(make_tuple(m.at(s.at(i)), (int)s.at(i).size(), s.at(i)));
    }
  }
  sort(t.begin(), t.end());
  for (int i = 0; i < 20; i++) {
    M = 0;
    for (int j = 0; j < 10; j++) {
      if (M + get<1>(t.front()) > 19) {
        break;
      }
      for (int k = 0; k < get<1>(t.front()); k++) {
        a.at(i).at(M + k) = get<2>(t.front()).at(k);
      }
      M += get<1>(t.front());
      t.pop_front();
    }
  }
  for (int i = 0; i < 20; i++) {
    for (int j = 0; j < 20; j++) {
      cout << a.at(i).at(j);
      if (j > 18) {
        cout << endl;
      }
    }
  }
}

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<string.h>
#include<random>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
#define rprintf(fmt, begin, end) do { const auto end_rp = (end); auto it_rp = (begin); for (bool sp_rp=0; it_rp!=end_rp; ++it_rp) { if (sp_rp) putchar(' '); else sp_rp = true; printf(fmt, *it_rp); } putchar('\n'); } while(0)

VI ans;
void rec(LL x, LL y, int dep) {
    if (ans.size() > 130u) return;

    if (x == y) {
	ans.push_back(4);
	REP (i, x) {
	    ans.push_back(1);
	    if (ans.size() > 130u) return;
	}

	// printf("%lld %lld %d\n", x, y, dep);
	return;
    }
    if (x > y) {
	ans.push_back(3);
	rec(x - y, y, dep+1);
    } else {
	ans.push_back(4);
	rec(x,  y - x, dep+1);
    }
}

// const long double GR = 2L / (1L + sqrt(5L));
const long double GR = 0.6180339887498948482045868343656381177203091798057628621354486227L;

bool solve(LL N) {
    ans.clear();
    if (N == 1) {
	ans.push_back(1);
	return true;
    }

    REP (i, 100) {
	LL tmpN = N-i;
	LL y = (long double)tmpN * GR;

	for (LL tmpy = y-30; tmpy <= y+30; tmpy++) {

	    if (tmpy > 0 && tmpy < tmpN && __gcd(tmpN, tmpy) == 1) {
		while ((int)ans.size() != i) ans.pop_back();
		rec(tmpN, tmpy, 0);
		if (ans.size() <= 130) {
		    return true;
		}
	    }
	}

	ans.push_back(1);
    }

    return false;
}

mt19937_64 engine;
void MAIN() {
    assert(solve(1));
    assert(solve(2));

    LL N;
#ifdef LOCALx
    REP (t, 100000) {
	N = engine() % 1000000000000000000LL + 1;
	printf("%lld\n", N);
	assert(solve(N));

    }
#endif

    scanf("%lld", &N);

    bool b = solve(N);
    assert(b);

    reverse(ans.begin(), ans.end());
    printf("%d\n", (int)ans.size());
    REP (i, ans.size()) printf("%d\n", ans[i]);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}

