#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
const double error = 1e-7;
const double PI = acos(-1);
mt19937 rng(
    (unsigned int)chrono::system_clock::now().time_since_epoch().count());
inline long long int MOD(long long int x, long long int m = mod) {
  long long int y = x % m;
  return (y >= 0) ? y : y + m;
}
const int inf = 1e9 + 5;
const long long int infl = 1e18 + 1;
const int nmax = 1e5 + 5;
vector<int> arr;
vector<pair<int, int> > output;
void unordered(int id, int cur, int goal, int tmp) {
  if (id + 1 == arr.size()) {
    for (int i = 0; i < arr[id]; i++) output.emplace_back(cur, goal);
    return;
  }
  unordered(id + 1, cur, tmp, goal);
  for (int i = 0; i < arr[id]; i++) output.emplace_back(cur, goal);
  unordered(id + 1, tmp, goal, cur);
  return;
}
void ordered(int id, int cur, int goal, int tmp) {
  if (id + 1 == arr.size()) {
    for (int i = 1; i < arr[id]; i++) output.emplace_back(cur, tmp);
    output.emplace_back(cur, goal);
    for (int i = 1; i < arr[id]; i++) output.emplace_back(tmp, goal);
    return;
  }
  if (arr[id] == 1) {
    unordered(id + 1, cur, tmp, goal);
    output.emplace_back(cur, goal);
    unordered(id + 1, tmp, goal, cur);
    return;
  }
  unordered(id + 1, cur, goal, tmp);
  for (int i = 0; i < arr[id]; i++) output.emplace_back(cur, tmp);
  unordered(id + 1, goal, cur, tmp);
  for (int i = 0; i < arr[id]; i++) output.emplace_back(tmp, goal);
  ordered(id + 1, cur, goal, tmp);
  return;
}
int main() {
  int n;
  cin >> n;
  vector<int> input(n);
  for (int i = 0; i < n; i++) cin >> input[i];
  for (int i = 0; i < n; i++) {
    int cnt = 1;
    while (i + 1 < input.size() && input[i] == input[i + 1]) cnt++, i++;
    arr.push_back(cnt);
  }
  ordered(0, 1, 3, 2);
  cout << output.size() << "\n";
  for (auto p : output) {
    cout << p.first << " " << p.second << "\n";
  }
}
