#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
pair<int, int> a[N], b[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n, i, r = 0, cut = 0;
    cin >> n;
    for (i = 0; i < n; ++i) cin >> a[i].first >> a[i].second, b[i] = a[i];
    sort(b, b + n);
    for (i = 1; i < n; ++i) {
      r = max(r, b[i - 1].second);
      if (b[i].first > r) cut = r;
    }
    if (cut)
      for (i = 0; i < n; ++i) cout << (a[i].first > cut) + 1 << ' ';
    else
      cout << -1;
    cout << "\n";
  }
  return 0;
}
