#include <bits/stdc++.h>
using namespace std;
const int MXN = 30;
bool cmp(const pair<int, pair<int, int> > &a,
         const pair<int, pair<int, int> > &b) {
  if (a.second.first == b.second.first)
    return a.second.second > b.second.second;
  return a.second.first < b.second.first;
}
void solve() {
  int i, t;
  cin >> t;
  int ans[t];
  vector<pair<int, pair<int, int> > > v(t);
  for (i = 0; i < t; i++) {
    cin >> v[i].second.first >> v[i].second.second;
    v[i].first = i;
  }
  sort(v.begin(), v.end(), cmp);
  int g1_max = 0, g2_max = 0;
  int choice = 2;
  bool ok1 = 0, ok2 = 0;
  for (i = 0; i < t; i++) {
    int se = v[i].first;
    int l = v[i].second.first;
    int r = v[i].second.second;
    if (choice == 1) {
      if (g1_max < l) {
        choice = 2;
        g2_max = max(g2_max, r);
        ans[se] = choice;
      } else {
        g1_max = max(g1_max, r);
        ans[se] = choice;
      }
    } else {
      if (g2_max < l) {
        choice = 1;
        g1_max = max(g1_max, r);
        ans[se] = choice;
      } else {
        g2_max = max(g2_max, r);
        ans[se] = choice;
      }
    }
    if (ans[se] == 1)
      ok1 = 1;
    else
      ok2 = 1;
  }
  if (ok1 && ok2) {
    for (i = 0; i < t; i++) cout << ans[i] << " ";
    cout << "\n";
  } else
    cout << -1 << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int test;
  cin >> test;
  while (test--) solve();
}
