#include <bits/stdc++.h>
using namespace std;
int z[111], a[222][2], x, y;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i << 1][0] >> a[(i << 1) + 1][0];
    ++z[a[i << 1][0]];
    ++z[a[(i << 1) + 1][0]];
  }
  for (int i = 10; i < 100; ++i) {
    if (z[i] == 1)
      if (x < y)
        ++x;
      else
        ++y;
    if (z[i] > 1) {
      ++x;
      ++y;
    }
  }
  cout << x * y << '\n';
  x = y = 0;
  for (int i = 0; i < (n << 1); ++i)
    if (z[a[i][0]] == 1) {
      if (x < y) {
        ++x;
        a[i][1] = 1;
      } else {
        ++y;
        a[i][1] = 2;
      }
      z[a[i][0]] = 0;
    }
  for (int i = 0; i < (n << 1); ++i) {
    if (z[a[i][0]] > 1) {
      z[a[i][0]] = -z[a[i][0]];
      a[i][1] = 1;
    } else if (z[a[i][0]] < 0) {
      z[a[i][0]] = abs(z[a[i][0]] + 2);
      a[i][1] = 2;
    }
  }
  for (int i = 0; i < (n << 1); ++i) {
    if (z[a[i][0]] && !a[i][1]) {
      if (x < y) {
        a[i][1] = 1;
        ++x;
      } else {
        a[i][1] = 2;
        ++y;
      }
      --z[a[i][0]];
    }
  }
  for (int i = 0; i < (n << 1); ++i) cout << a[i][1] << ' ';
}
