#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
long long qpow(long long x, long long y) {
  long long s = 1;
  while (y) {
    if (y & 1) s = s * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return s;
}
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * f;
}
long long inve(long long x) {
  return x == 1 ? 1 : (mod - mod / x) * inve(mod % x) % mod;
}
const int M = 998244353;
int i, s, ans[100005], p, n, T, j;
struct str {
  int l, r, x;
} a[100005];
bool cmp(str a, str b) { return a.r < b.r; }
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
      scanf("%d%d", &a[i].l, &a[i].r);
      a[i].x = i;
    }
    sort(a + 1, a + 1 + n, cmp);
    p = 1;
    s = 1 << 30;
    for (i = n; i >= 2; i--) {
      s = min(s, a[i].l);
      if (s > a[i - 1].r) {
        p = 0;
        for (j = 1; j < i; j++) ans[a[j].x] = 1;
        for (j = i; j <= n; j++) ans[a[j].x] = 2;
        break;
      }
    }
    if (p)
      printf("-1\n");
    else {
      for (i = 1; i < n; i++) printf("%d ", ans[i]);
      printf("%d\n", ans[n]);
    }
  }
  return 0;
}
