#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long i, a[n];
    pair<pair<long long, long long>, long long> p[n];
    for (i = 0; i < n; i++) {
      cin >> p[i].first.first >> p[i].first.second;
      p[i].second = i;
    }
    long long l1, r1, l2 = LONG_MAX, r2 = LONG_MIN, ind = LONG_MAX;
    sort(p, p + n);
    l1 = p[0].first.first;
    r1 = p[0].first.second;
    a[p[0].second] = 1;
    for (i = 1; i < n; i++) {
      if (p[i].first.first > r1) {
        l2 = p[i].first.first;
        r2 = p[i].first.second;
        a[p[i].second] = 2;
        ind = i;
        break;
      } else {
        r1 = max(r1, p[i].first.second);
        a[p[i].second] = 1;
      }
    }
    for (i = ind; i < n; i++) a[p[i].second] = 2;
    if ((l2 != LONG_MAX && r2 != LONG_MIN)) {
      for (i = 0; i < n; i++) {
        cout << a[i] << " ";
      }
      cout << endl;
    } else
      cout << "-1\n";
  }
  return 0;
}
