#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    vector<pair<int, pair<int, int>>> v;
    int n, x, y;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> x >> y;
      v.push_back({x, {y, i}});
    }
    sort(v.begin(), v.end());
    int m1 = 0, m2 = -1, flag = 1;
    int ans[n + 3];
    ans[v[0].second.second] = 1;
    m1 = v[0].second.first;
    for (int i = 1; i <= n - 1; i++) {
      if (v[i].first <= m1) {
        ans[v[i].second.second] = 1;
        m1 = max(m1, v[i].second.first);
      } else
        m2 = i, ans[v[i].second.second] = 2;
    }
    if (m2 == -1) {
      cout << -1 << '\n';
      continue;
    }
    for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
    cout << '\n';
  }
}
