#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    vector<pair<pair<long long int, long long int>, long long int>> v;
    long long int i, j, q, r, t;
    long long int n;
    i = 0;
    cin >> n;
    long long int m = n;
    long long int a[n + 5];
    while (m--) {
      cin >> q >> r;
      v.push_back(make_pair(make_pair(q, r), i));
      i++;
    }
    sort(v.begin(), v.end());
    long long int p = 1, mx = 0;
    for (i = 0; i < n; i++) {
      a[v[i].second] = p;
      mx = max(mx, v[i].first.second);
      if (mx < v[i + 1].first.first && p == 1 && i < n - 1) {
        p++;
      }
    }
    if (p == 1) {
      cout << -1 << endl;
      continue;
    }
    for (i = 0; i < n; i++) {
      cout << a[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
