#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int maxn = 1002;
void solve() {
  long long n;
  cin >> n;
  long long ans[n];
  pair<long long, long long> p[n];
  long long a[n], b[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
    p[i] = make_pair(a[i], i);
  }
  sort(p, p + n);
  int val = 1;
  long long right = b[p[0].second];
  for (int i = 0; i < n; ++i) {
    if (p[i].first <= right) {
      ans[p[i].second] = val;
      right = max(right, b[p[i].second]);
    } else {
      if (val == 1) {
        val++;
        ans[p[i].second] = val;
      } else {
        ans[p[i].second] = val;
      }
      right = max(right, b[p[i].second]);
    }
  }
  if (val == 2) {
    for (int i = 0; i < n; ++i) {
      cout << ans[i] << ' ';
    }
  } else {
    cout << -1 << ' ';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) {
    solve();
    cout << endl;
  }
  return 0;
}
