#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")
using namespace std;
struct range {
  long long l, r, index;
};
bool comp(struct range r1, struct range r2) {
  if (r1.l != r2.l)
    return r1.l < r2.l;
  else
    return r1.r < r2.r;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    range v[n];
    for (long long i = 0; i < n; i++) {
      cin >> v[i].l >> v[i].r;
      v[i].index = i;
    }
    sort(v, v + n, comp);
    set<pair<long long, long long>> s;
    long long ans[n];
    bool ch = 1;
    long long c = 0;
    long long fans[n];
    for (long long i = 0; i < n; i++) {
      while (!s.empty() and (*s.begin()).first < v[i].l) {
        s.erase(s.begin());
      }
      if (s.size() >= 1) {
        if (ans[(*s.begin()).second] == 2) {
          ans[i] = 2;
          c = 2;
        } else
          ans[i] = 1;
      }
      if (s.size() == 0) {
        if (c == 0) {
          ans[i] = 1;
          c = 1;
        } else {
          ans[i] = 2;
          c = 2;
        }
      }
      s.insert({v[i].r, i});
    }
    if (ch and c == 2) {
      for (long long i = 0; i < n; i++) {
        fans[v[i].index] = ans[i];
      }
      for (long long i = 0; i < n; i++) cout << fans[i] << " ";
    } else
      cout << -1;
    cout << "\n";
  }
}
