#include <bits/stdc++.h>
using namespace std;
bool primeCheck(long long n) {
  if (n % 2 == 0) return false;
  for (long long i = 3; i * i <= n; i += 2) {
    if (n % i == 0) return false;
  }
  return true;
}
string twostringdigitsum(string a, string b) {
  string s = "";
  while (a.size() < b.size()) {
    a = '0' + a;
  }
  while (a.size() > b.size()) {
    b = '0' + b;
  }
  long long c = 0;
  for (long long i = a.size() - 1; i >= 0; i--) {
    c += (a[i] - '0') + (b[i] - '0');
    s = char((c % 10) + '0') + s;
    c /= 10;
  }
  while (c > 0) {
    s = char((c % 10) + '0') + s;
    c /= 10;
  }
  return s;
}
long long stringdigitsum(string digits) {
  long long num, total = 0;
  for (int i = 0; i < digits.length(); i++) {
    num = digits.at(i) - '0';
    assert(0 <= num && num <= 9);
    total += num;
  }
  return total;
}
long long integerdigitsum(long long n) {
  long long sum = 0;
  while (1) {
    if (n < 10) {
      sum += n;
      break;
    } else {
      sum += n % 10;
      n /= 10;
    }
  }
  return sum;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t, n, i, x, y;
  string str;
  cin >> t;
  while (t--) {
    vector<pair<pair<long long, long long>, long long>> p;
    cin >> n;
    long long ans[n + 10];
    for (i = 0; i < n; i++) {
      cin >> x >> y;
      p.push_back(make_pair(make_pair(x, y), i));
    }
    sort(p.begin(), p.end());
    long long mx, ck = 0;
    mx = p[0].first.second;
    for (i = 0; i < n; i++) {
      if (p[i].first.first <= mx) {
        mx = max(mx, p[i].first.second);
        ans[p[i].second] = 1;
      } else {
        ans[p[i].second] = 2;
        ck = 1;
      }
    }
    if (!ck)
      cout << "-1" << endl;
    else {
      for (i = 0; i < n; i++) cout << ans[i] << ' ';
      cout << endl;
    }
  }
  return 0;
}
