#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool read(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c<'0' | c> '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
template <class T>
inline long long gcd(T a, T b) {
  a = abs(a);
  b = abs(b);
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
template <class T>
inline long long ext_gcd(T A, T B, T *X, T *Y) {
  T x2, y2, x1, y1, x, y, r2, r1, q, r;
  x2 = 1;
  y2 = 0;
  x1 = 0;
  y1 = 1;
  for (r2 = A, r1 = B; r1 != 0;
       r2 = r1, r1 = r, x2 = x1, y2 = y1, x1 = x, y1 = y) {
    q = r2 / r1;
    r = r2 % r1;
    x = x2 - (q * x1);
    y = y2 - (q * y1);
  }
  *X = x2;
  *Y = y2;
  return r2;
}
template <class T>
inline long long modInv(T a, T m) {
  T x, y;
  ext_gcd(a, m, &x, &y);
  x %= m;
  if (x < 0) x += m;
  return x;
}
template <class T>
inline long long power(T a, T p) {
  T res = 1, x = a;
  while (p) {
    if (p & 1) res = (res * x);
    x = (x * x);
    p >>= 1;
  }
  return res;
}
template <class T>
inline long long bigmod(T a, T p, T m) {
  T res = 1 % m, x = a % m;
  while (p) {
    if (p & 1) res = (res * x) % m;
    x = (x * x) % m;
    p >>= 1;
  }
  return res;
}
struct node {
  int x, y, pos, group;
  node(int _x, int _y, int _pos, int _group) {
    x = _x;
    y = _y;
    pos = _pos;
    group = _group;
  }
};
vector<int> ans;
vector<node> v;
bool cmp(node a, node b) {
  if (a.y == b.y) return a.x < b.x;
  return a.x < b.x;
}
bool cmp2(node a, node b) { return a.pos < b.pos; }
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    v.clear();
    int n;
    cin >> n;
    int l, r;
    for (int i = 1; i <= n; i++) {
      cin >> l >> r;
      v.push_back(node(l, r, i, -1));
    }
    sort(v.begin(), v.end(), cmp);
    int firstGroupMax = v[0].y, secondGroupMax = -1;
    v[0].group = 1;
    bool Two = 0;
    for (int i = 1; i < n; i++) {
      int current = v[i].x;
      if (current > firstGroupMax && Two == 0) {
        v[i].group = 2;
        Two = 1;
        secondGroupMax = v[i].y;
      } else if (current <= firstGroupMax) {
        v[i].group = 1;
        firstGroupMax = max(v[i].y, firstGroupMax);
      } else if (current <= secondGroupMax) {
        v[i].group = 2;
        secondGroupMax = max(v[i].y, secondGroupMax);
      } else {
        v[i].group = 1;
        firstGroupMax = max(v[i].y, firstGroupMax);
      }
    }
    sort(v.begin(), v.end(), cmp2);
    if (!Two) {
      puts("-1");
      continue;
    }
    bool isAvailable = 0, isMinus = 0;
    for (int i = 0; i < n; i++) {
      if (v[i].group == -1) {
        isMinus = 1;
        break;
      }
    }
    if (isMinus) {
      puts("-1");
    } else {
      for (int i = 0; i < n; i++) {
        printf("%d ", v[i].group);
      }
      puts("");
    }
  }
  return 0;
}
