#include <bits/stdc++.h>
using namespace std;
long long t, x = -1, c, i, y, n, k, j, idx, res, flag;
vector<long long> v1, v2;
string s;
vector<pair<long long, long long> > vp, vp1;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> t;
  while (t--) {
    cin >> n;
    for (i = 0; i < n; i++)
      cin >> x >> y, vp.push_back(make_pair(x, y)),
          vp1.push_back(make_pair(x, y));
    sort(vp.begin(), vp.end());
    x = vp[0].second;
    for (i = 1; i < vp.size(); i++) {
      if (x >= vp[i].first && vp[i].second >= x) {
        idx = i, x = vp[i].second;
      }
    }
    if (idx + 1 == vp.size())
      flag = 1;
    else {
      for (i = 0; i < vp1.size(); i++) {
        if (x >= vp1[i].second)
          res++, v2.push_back(1);
        else
          v2.push_back(2);
      }
    }
    if (v2.size() == res || flag)
      cout << -1 << "\n";
    else {
      for (i = 0; i < v2.size(); i++) cout << v2[i] << " ";
      cout << "\n";
    }
    vp.clear();
    vp1.clear();
    v2.clear();
    idx = 0;
    flag = 0;
    res = 0;
  }
  return 0;
}
