#include <bits/stdc++.h>
using namespace std;
struct node {
  int L, R, id;
} segment[100005];
int ans[100005];
int n;
bool comp(node xx, node yy) {
  if (xx.L < yy.L) return true;
  if (xx.L > yy.L) return false;
  return xx.R < yy.R;
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
      segment[i].id = i;
      scanf("%d%d", &segment[i].L, &segment[i].R);
    }
    sort(segment + 1, segment + n + 1, comp);
    int flag = -1, mx = segment[1].R;
    for (int i = 2; i <= n; ++i) {
      if (segment[i].L > mx) {
        flag = i;
        break;
      }
      mx = max(mx, segment[i].R);
    }
    if (flag == -1) {
      printf("-1\n");
      continue;
    }
    for (int i = 1; i < flag; ++i) ans[segment[i].id] = 1;
    for (int i = flag; i <= n; ++i) ans[segment[i].id] = 2;
    for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
    printf("\n");
  }
  return 0;
}
