#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long mod = 1e9 + 7;
void sout() { cout << "\n"; }
template <typename T, typename... Types>
void sout(T var1, Types... var2) {
  cout << var1 << " ";
  sout(var2...);
}
long long n, m;
long long temp;
long long cnt;
long long ans;
long long ind;
bool static cmp(const pair<pair<long long, long long>, long long> &a,
                const pair<pair<long long, long long>, long long> &b) {
  if (a.first.second != b.first.second) return a.first.second < b.first.second;
  if (a.first.first != b.first.first) return a.first.first < b.first.first;
  return a.second < b.second;
}
void test_case() {
  long long n;
  vector<pair<pair<long long, long long>, long long> > segs;
  cin >> n;
  segs.resize(n);
  for (long long i = 0; i < n; i++) {
    cin >> segs[i].first.first >> segs[i].first.second;
    segs[i].second = i;
  }
  sort(segs.begin(), segs.end(), cmp);
  long long mn = segs[n - 1].first.first;
  for (long long i = n - 2; i >= 0; i--) {
    if (segs[i].first.second < mn) {
      vector<long long> ts(n, 2);
      for (long long id = 0; id <= i; id++) ts[segs[id].second] = 1;
      for (long long t : ts) cout << t << ' ';
      cout << '\n';
      return;
    }
    mn = min(mn, segs[i].first.first);
  }
  cout << -1 << '\n';
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  long long t = 1;
  cin >> t;
  while (t--) {
    test_case();
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}
