#include <bits/stdc++.h>
using namespace std;
void init_code() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int main() {
  init_code();
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<pair<int, int>> v;
    vector<pair<int, int>> v1;
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      v1.push_back({x, y});
      v.push_back({x, y});
    }
    sort(v.begin(), v.end());
    int st = v[0].first;
    int ed = v[0].second;
    int cnt = 1;
    unordered_map<int, int> mp;
    mp[st] = 1;
    for (int i = 1; i < n; i++) {
      if (v[i].first <= ed) {
        mp[v[i].first] = cnt;
        ed = max(ed, v[i].second);
      } else {
        st = v[i].first;
        ed = v[i].second;
        if (cnt == 1) {
          cnt++;
        }
        mp[v[i].first] = cnt;
      }
    }
    if (cnt < 2) {
      cout << "-1" << endl;
    } else {
      for (int i = 0; i < v1.size(); i++) {
        cout << mp[v1[i].first] << " ";
      }
      cout << endl;
    }
  }
  return 0;
}
