#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  while (T--) {
    vector<pair<int, int> > segs, segs2;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
      int l, r;
      pair<int, int> p;
      cin >> p.first >> p.second;
      segs.push_back(p);
      segs2.push_back(p);
    }
    int val = -1;
    sort(segs.begin(), segs.end());
    int mx = 0;
    for (int i = 0; i < n - 1; i++) {
      if (segs[i].second < segs[i + 1].first && segs[i + 1].first > mx) {
        val = segs[i + 1].first;
      }
      mx = max(mx, segs[i].second);
    }
    if (val == -1)
      cout << "-1\n";
    else {
      for (int i = 0; i < segs2.size(); i++) {
        if (segs2[i].first < val && segs2[i].second < val)
          cout << "1 ";
        else
          cout << "2 ";
      }
    }
  }
  return 0;
}
