#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
vector<pair<string,string>> res2 = {
{"Z0","Z"},
{"Z1","Z"},
{"0Z","Z"},
{"1Z","Z"},
{"0M","M0"},
{"1M","M1"},
{"0N","N0"},
{"1N","N1"},
{"0BM","B"},
{"1BN","B"},
{"BM","Z"},
{"BN","Z"},
{"H0","0H"},
{"H1","1H"},
{"HE","C"},
{"D","BH"},
{"C00","00E"},
{"C01","01E"},
{"C10","10E"},
{"C11","11E"},
{"C0","Z"},
{"C1","Z"},
{"0C","MC"},
{"1C","NC"},
{"BC","_"},
{"B0","0D"},
{"B1","1D"},
{"1A","A1"},
{"A","BC"},
{"0","A0"},
{"11","_"}};
vector<pair<string,string>> res3 = {
{"Z0","Z"},
{"Z1","Z"},
{"0Z","Z"},
{"1Z","Z"},
{"0X","X0"},
{"1X","X1"},
{"0Y","Y0"},
{"1Y","Y1"},
{"0AX","A"},
{"1AY","A"},
{"AX","Z"},
{"AY","Z"},
{"0BX","XB"},
{"1BY","YB"},
{"BX","Z"},
{"BY","Z"},
{"Q0","0Q"},
{"Q1","1Q"},
{"QH","C"},
{"QG","BQ"},
{"F","AQ"},
{"C000","000H"},
{"C001","001H"},
{"C010","010H"},
{"C011","011H"},
{"C100","100H"},
{"C101","101H"},
{"C110","110H"},
{"C111","111H"},
{"C0","Z"},
{"C1","Z"},
{"0C","XC"},
{"1C","YC"},
{"B00","00G"},
{"B01","01G"},
{"B10","10G"},
{"B11","11G"},
{"ABC","_"},
{"A0","0F"},
{"A1","1F"},
{"1W","W1"},
{"W","ABC"},
{"0","W0"},
{"111","_"}};
vector<pair<string,string>> res4 = {
{"Z0","Z"},
{"Z1","Z"},
{"0Z","Z"},
{"1Z","Z"},
{"0X","X0"},
{"1X","X1"},
{"0Y","Y0"},
{"1Y","Y1"},
{"0AX","A"},
{"1AY","A"},
{"AX","Z"},
{"AY","Z"},
{"0BX","XB"},
{"1BY","YB"},
{"BX","Z"},
{"BY","Z"},
{"0CX","XC"},
{"1CY","YC"},
{"CX","Z"},
{"CY","Z"},
{"Q0","0Q"},
{"Q1","1Q"},
{"QI","D"},
{"QH","CQ"},
{"QG","BQ"},
{"F","AQ"},
{"D0000","0000I"},
{"D0001","0001I"},
{"D0010","0010I"},
{"D0011","0011I"},
{"D0100","0100I"},
{"D0101","0101I"},
{"D0110","0110I"},
{"D0111","0111I"},
{"D1000","1000I"},
{"D1001","1001I"},
{"D1010","1010I"},
{"D1011","1011I"},
{"D1100","1100I"},
{"D1101","1101I"},
{"D1110","1110I"},
{"D1111","1111I"},
{"D0","Z"},
{"D1","Z"},
{"0D","XD"},
{"1D","YD"},
{"C000","000H"},
{"C001","001H"},
{"C010","010H"},
{"C011","011H"},
{"C100","100H"},
{"C101","101H"},
{"C110","110H"},
{"C111","111H"},
{"B00","00G"},
{"B01","01G"},
{"B10","10G"},
{"B11","11G"},
{"ABCD","_"},
{"A0","0F"},
{"A1","1F"},
{"1W","W1"},
{"W","ABCD"},
{"0","W0"},
{"1111","_"}};
vector<pair<string,string>> res5 = {
{"Z0","Z"},
{"Z1","Z"},
{"0Z","Z"},
{"1Z","Z"},
{"0X","X0"},
{"1X","X1"},
{"0Y","Y0"},
{"1Y","Y1"},
{"0AX","A"},
{"1AY","A"},
{"AX","Z"},
{"AY","Z"},
{"0BX","XB"},
{"1BY","YB"},
{"BX","Z"},
{"BY","Z"},
{"0CX","XC"},
{"1CY","YC"},
{"CX","Z"},
{"CY","Z"},
{"0DX","XD"},
{"1DY","YD"},
{"DX","Z"},
{"DY","Z"},
{"Q0","0Q"},
{"Q1","1Q"},
{"QJ","E"},
{"QI","DQ"},
{"QH","CQ"},
{"QG","BQ"},
{"F","AQ"},
{"E00000","00000J"},
{"E00001","00001J"},
{"E00010","00010J"},
{"E00011","00011J"},
{"E00100","00100J"},
{"E00101","00101J"},
{"E00110","00110J"},
{"E00111","00111J"},
{"E01000","01000J"},
{"E01001","01001J"},
{"E01010","01010J"},
{"E01011","01011J"},
{"E01100","01100J"},
{"E01101","01101J"},
{"E01110","01110J"},
{"E01111","01111J"},
{"E10000","10000J"},
{"E10001","10001J"},
{"E10010","10010J"},
{"E10011","10011J"},
{"E10100","10100J"},
{"E10101","10101J"},
{"E10110","10110J"},
{"E10111","10111J"},
{"E11000","11000J"},
{"E11001","11001J"},
{"E11010","11010J"},
{"E11011","11011J"},
{"E11100","11100J"},
{"E11101","11101J"},
{"E11110","11110J"},
{"E11111","11111J"},
{"E0","Z"},
{"E1","Z"},
{"0E","XE"},
{"1E","YE"},
{"D0000","0000I"},
{"D0001","0001I"},
{"D0010","0010I"},
{"D0011","0011I"},
{"D0100","0100I"},
{"D0101","0101I"},
{"D0110","0110I"},
{"D0111","0111I"},
{"D1000","1000I"},
{"D1001","1001I"},
{"D1010","1010I"},
{"D1011","1011I"},
{"D1100","1100I"},
{"D1101","1101I"},
{"D1110","1110I"},
{"D1111","1111I"},
{"C000","000H"},
{"C001","001H"},
{"C010","010H"},
{"C011","011H"},
{"C100","100H"},
{"C101","101H"},
{"C110","110H"},
{"C111","111H"},
{"B00","00G"},
{"B01","01G"},
{"B10","10G"},
{"B11","11G"},
{"ABCDE","_"},
{"A0","0F"},
{"A1","1F"},
{"1W","W1"},
{"W","ABCDE"},
{"0","W0"},
{"11111","_"}};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n; cin >> n;
vector<pair<string,string>> res;
if (n == 2) res = res2;
if (n == 3) res = res3;
if (n == 4) res = res4;
if (n == 5) res = res5;
cout << sz(res) << endl;
for (auto p: res) cout << p.xx << " -> " << p.yy << endl;
}