#include <bits/stdc++.h>
using namespace std;
long n, d[200], calc;
vector<long> v;
vector<pair<long, long> > ans;
void add_move(long a, long b) { ans.push_back(make_pair(a + 1, b + 1)); }
void solve_clear(vector<long> v, long a, long b);
void solve_dirt(vector<long> v, long start, long finish) {
  if (v.size() == 1) {
    for (int i = 0; i < v[0]; i++) add_move(start, finish);
    return;
  }
  long temp = v.back();
  v.pop_back();
  solve_dirt(v, start, 3 ^ start ^ finish);
  for (int i = 0; i < temp; i++) add_move(start, finish);
  solve_dirt(v, 3 ^ start ^ finish, finish);
}
void solve_clear(vector<long> v, long start, long finish) {
  if (v.size() == 1) {
    for (int i = 0; i < v[0] - 1; i++) add_move(start, 3 ^ start ^ finish);
    add_move(start, finish);
    for (int i = 0; i < v[0] - 1; i++) add_move(3 ^ start ^ finish, finish);
    return;
  }
  if (v[v.size() - 1] == 1) {
    solve_dirt(v, start, finish);
    return;
  }
  long temp = v.back();
  v.pop_back();
  solve_dirt(v, start, finish);
  for (int i = 0; i < temp; i++) add_move(start, 3 ^ start ^ finish);
  solve_dirt(v, finish, start);
  for (int i = 0; i < temp; i++) add_move(3 ^ start ^ finish, finish);
  solve_clear(v, start, finish);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
    if (i > 1 && d[i] != d[i - 1]) {
      v.push_back(calc);
      calc = 1;
    } else
      ++calc;
  }
  v.push_back(calc);
  reverse(v.begin(), v.end());
  solve_clear(v, 0, 2);
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first << " " << ans[i].second << "\n";
  }
  cin.get();
  cin.get();
  return 0;
}
