#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    vector<pair<pair<int, int>, int>> a(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i].first.first >> a[i].first.second;
      a[i].second = i;
    }
    sort(a.begin(), a.end());
    vector<int> ans(n);
    int s1 = 0, s2 = 0;
    for (int i = 0; i < n; i++) {
      if (a[i].first.first <= s1 || s1 == 0)
        ans[a[i].second] = 1, s1 = max(s1, a[i].first.second);
      else
        ans[a[i].second] = 2, s2 = max(s2, a[i].first.second);
    }
    if (s2 == 0) {
      cout << -1 << "\n";
      continue;
    }
    for (int i = 0; i < n; i++) cout << ans[i] << " ";
    cout << "\n";
  }
  return 0;
}
