#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  cin >> TESTS;
  while (TESTS--) {
    long long n;
    cin >> n;
    pair<pair<long long, long long>, long long> p[n];
    long long ans[n];
    for (long long i = 0; i < n; i++) {
      cin >> p[i].first.first >> p[i].first.second;
      p[i].second = i;
    }
    sort(p, p + n);
    long long x = 1;
    ans[p[0].second] = 1;
    long long mr = p[0].first.second;
    for (long long i = 1; i < n; i++) {
      if ((x != 2) && (p[i].first.first > mr)) x = 2;
      ans[p[i].second] = x;
      mr = max(mr, p[i].first.second);
    }
    if (x == 1)
      cout << -1;
    else {
      for (long long i = 0; i < n; i++) cout << ans[i] << ' ';
    }
    cout << '\n';
  }
  return 0;
}
