#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 maxn = 2e5 + 5;
struct node {
  int l, r, id;
};
vector<node> v;
bool cmp(node a, node b) {
  if (a.l == b.l) return a.r < b.r;
  return a.l < b.l;
}
int ans[maxn];
int main() {
  int n, t;
  scanf("%d", &t);
  while (t--) {
    v.clear();
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      int l, r;
      scanf("%d%d", &l, &r);
      v.push_back((node){l, r, i});
    }
    sort(v.begin(), v.end(), cmp);
    int st = v[0].l, ed = v[0].r;
    int flag = 0;
    ans[v[0].id] = 1;
    for (int i = 1; i < n; i++) {
      node tmp = v[i];
      if (tmp.l <= st && tmp.r >= ed) {
        st = tmp.l;
        ed = tmp.r;
        ans[v[i].id] = 1;
      } else if (tmp.l <= ed && tmp.r <= ed) {
        ans[v[i].id] = 1;
      } else if (tmp.l <= ed && tmp.r > ed) {
        ed = tmp.r;
        ans[v[i].id] = 1;
      } else if (tmp.l > ed) {
        flag = 1;
        ans[v[i].id] = 2;
      }
    }
    if (flag) {
      for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
      printf("\n");
    } else
      puts("-1");
  }
  return 0;
}
