#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 200;
int T, n, ans[N];
struct node {
  int x, y, id;
  bool operator<(const node rhs) const {
    if (x != rhs.x)
      return x < rhs.x;
    else
      return y < rhs.y;
  }
} G[N];
int main() {
  for (scanf("%d", &T); T--;) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d%d", &G[i].x, &G[i].y), G[i].id = i;
    sort(G + 1, G + n + 1);
    int l = G[1].x, r = G[1].y, x = 2147483647, y = 0;
    ans[G[1].id] = 1;
    for (int i = 2; i <= n; i++)
      if (G[i].x <= r)
        r = max(r, G[i].y), ans[G[i].id] = 1;
      else {
        x = min(G[i].x, x);
        y = max(y, G[i].y);
        ans[G[i].id] = 2;
      }
    if (x <= r and x >= l or y <= r and y >= l or y == 0)
      printf("-1\n");
    else {
      for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
      printf("\n");
    }
  }
}
