#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int N = 1e5 + 5;
int n;
tuple<int, int, int> v[N];
int ans[N];
bool go(int i, int j, int k) {
  int Li, Lj, Lk, Ri, Rj, Rk;
  tie(Li, Ri, ignore) = v[i];
  tie(Lj, Rj, ignore) = v[j];
  tie(Lk, Rk, ignore) = v[k];
  int l = max(Li, max(Lj, Lk));
  int r = max(Ri, max(Rj, Rk));
  return (l <= r);
}
void go() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    v[i] = make_tuple(l, r, i);
  }
  sort(v, v + n);
  int r, id;
  tie(ignore, r, id) = v[0];
  ans[id] = 1;
  int at = 0;
  for (int i = 1; i < n; i++) {
    int L, R, id;
    tie(L, R, id) = v[i];
    if (L > r) at = 1;
    ans[id] = at + 1;
    r = max(r, R);
  }
  bool f = false;
  for (int i = 0; i < n; i++)
    if (ans[i] == 2) f = true;
  if (!f) {
    printf("-1\n");
    return;
  }
  for (int i = 0; i < n; i++) printf("%d%c", ans[i], " \n"[i == n - 1]);
}
int main(void) {
  int T;
  scanf("%d", &T);
  while (T--) go();
  return 0;
}
