#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-12;
const int INF = 1 << 30;
int n, m;
int c[20];
vector<pair<char, char> > res;
void Init() {
  int a[20];
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[n - 1 - i]);
  m = 1;
  c[0] = 1;
  for (int i = 1; i < n; ++i) {
    if (a[i] == a[i - 1])
      ++c[m - 1];
    else
      c[m++] = 1;
  }
}
void Move(int x, int& mask, int S, int T) {
  if (x == 0) return;
  int M = 6 - S - T;
  Move(x - 1, mask, S, M);
  for (int i = c[x - 1]; i >= 1; --i) res.push_back(make_pair(S, T));
  mask ^= (1 << (x - 1));
  Move(x - 1, mask, M, T);
}
void Solve(int x, int mask, int S, int T) {
  if (x == 0) return;
  int M = 6 - S - T;
  bool rev = (mask >> (x - 1)) & 1;
  if (rev || c[x - 1] == 1) {
    Move(x - 1, mask, S, M);
    for (int i = c[x - 1]; i >= 1; --i) res.push_back(make_pair(S, T));
    Solve(x - 1, mask, M, T);
  } else if (x == 1) {
    for (int i = c[0]; i >= 2; --i) res.push_back(make_pair(S, M));
    res.push_back(make_pair(S, T));
    for (int i = c[0]; i >= 2; --i) res.push_back(make_pair(M, T));
    Solve(x - 1, mask, S, T);
  } else {
    Move(x - 1, mask, S, T);
    for (int i = c[x - 1]; i >= 1; --i) res.push_back(make_pair(S, M));
    Move(x - 1, mask, T, S);
    for (int i = c[x - 1]; i >= 1; --i) res.push_back(make_pair(M, T));
    Solve(x - 1, mask, S, T);
  }
}
int main() {
  Init();
  res.reserve(1 << n);
  Solve(m, 0, 1, 3);
  printf("%d\n", int((res).size()));
  for (typeof((res).begin()) i = (res).begin(); i != (res).end(); i++)
    printf("%d %d\n", (int)i->first, (int)i->second);
  return 0;
}
