#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
struct Node {
  int fi, se, idx;
} arr[100005];
int res[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> arr[i].fi >> arr[i].se;
      arr[i].idx = i;
    }
    sort(arr, arr + n, [](Node a, Node b) {
      if (a.fi == b.fi) {
        return a.se < b.se;
      }
      return a.fi < b.fi;
    });
    bool switched = false;
    int lastgr = 1, span;
    for (int i = 0; i < n; i++) {
      if (i == 0) {
        span = arr[i].se;
        res[arr[i].idx] = lastgr;
        continue;
      }
      if (arr[i].fi <= span) {
        res[arr[i].idx] = lastgr;
        span = max(arr[i].se, span);
      } else {
        lastgr = (lastgr == 1 ? 2 : 1);
        switched = true;
        res[arr[i].idx] = lastgr;
        span = arr[i].se;
      }
    }
    if (switched) {
      for (int i = 0; i < n; i++) {
        cout << res[i] << ' ';
      }
      cout << '\n';
    } else {
      cout << -1 << '\n';
    }
  }
  return 0;
}
