#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<pair<int, pair<int, int>>> v;
    for (int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      v.push_back(make_pair(a, make_pair(b, i)));
    }
    sort(v.begin(), v.end());
    int g[100001]{}, r = v[0].second.first;
    g[v[0].second.second] = 1;
    for (int i = 1; i < n; i++) {
      if (v[i].first > r) break;
      g[v[i].second.second] = 1;
      r = max(r, v[i].second.first);
    }
    bool ans = true;
    for (int i = 0; i < n && ans; i++) ans &= g[i];
    if (ans) {
      cout << -1 << '\n';
      continue;
    }
    for (int i = 0; i < n; i++) cout << g[i] + 1 << " ";
    cout << '\n';
  }
}
