#include <bits/stdc++.h>
using namespace std;
int T;
int n;
pair<int, pair<int, int> > a[100005];
int r[100005];
int parts, now;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> T;
  for (int t = 1; t <= T; t++) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a[i].first >> a[i].second.first;
      a[i].second.second = i;
    }
    sort(a + 1, a + n + 1);
    parts = 1, now = 1;
    r[a[1].second.second] = 1;
    int l = a[1].second.first;
    for (int i = 2; i <= n; i++) {
      if (a[i].first > l) now = 2, parts++;
      r[a[i].second.second] = now, l = max(l, a[i].second.first);
    }
    if (parts > 1) {
      for (int i = 1; i <= n; i++) cout << r[i] << " ";
      cout << "\n";
    } else
      cout << "-1\n";
  }
  return 0;
}
