#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, res = -1, i, t1, t2, tt;
    vector<pair<int, int> > vp, vp2;
    cin >> n;
    for (i = 0; i < n; i++) {
      cin >> t1 >> t2;
      vp.push_back(make_pair(t1, t2));
      vp2.push_back(make_pair(t1, t2));
    }
    sort(vp2.begin(), vp2.end());
    tt = vp2[0].second;
    for (i = 1; i < n; i++) {
      tt = max(tt, vp2[i - 1].second);
      if (vp2[i].first > tt) res = vp2[i].first;
    }
    if (res == -1)
      cout << -1 << endl;
    else
      for (i = 0; i < n; i++) {
        if (vp[i].second < res) {
          if (i < (n - 1))
            cout << 1 << " ";
          else
            cout << 1 << endl;
        } else {
          if (i < (n - 1))
            cout << 2 << " ";
          else
            cout << 2 << endl;
        }
      }
  }
}
