#include <bits/stdc++.h>
using namespace std;
const double PI = 3.141592653589793;
const long long I_MAX = 1LL << 60;
const long long mod = 1000000007;
void precal() { return; }
bool cmp(pair<long long, pair<long long, long long> > a,
         pair<long long, pair<long long, long long> > b) {
  if (a.first != b.first)
    return a.first < b.first;
  else
    a.second.first > b.second.first;
}
bool solve() {
  long long n = 1, tok = 0, cnt = 0;
  if (cin >> n)
    ;
  else
    return false;
  vector<pair<long long, pair<long long, long long> > > num(n);
  for (auto &x : num) {
    cin >> x.first >> x.second.first;
    x.second.second = tok++;
  }
  sort(num.begin(), num.end(), cmp);
  long long r_max = num[0].second.first;
  bool place[n];
  memset(place, false, sizeof(place));
  for (int i = 0; i < n; ++i) {
    if (num[i].first <= r_max) {
      r_max = max(r_max, num[i].second.first);
      place[num[i].second.second] = true;
      cnt++;
    }
  }
  if (cnt == n)
    cout << -1;
  else
    for (int i = 0; i < n; ++i) cout << place[i] + 1 << ' ';
  cout << '\n';
  return true;
}
int main() {
  precal();
  int t = INT_MAX;
  cin >> t;
  for (int i = 1; i <= t; ++i) {
    if (!solve()) break;
  }
  return 0;
}
