#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int N;
    scanf("%d", &N);
    vector<pair<pair<int, int>, int> > v;
    pair<pair<int, int>, int> aux;
    for (int i = (int)0; i < (int)N; i++) {
      scanf("%d %d", &aux.first.first, &aux.first.second);
      aux.second = i;
      v.push_back(aux);
    }
    sort(v.begin(), v.end());
    vector<int> ans(N, 0);
    int mx = v[0].first.second, yep = 1;
    for (int i = (int)1; i < (int)v.size(); i++) {
      while (i < v.size() && v[i].first.first <= mx) {
        mx = max(mx, v[i].first.second);
        i++;
      }
      if (i == v.size()) {
        yep = 0;
        break;
      }
      for (int j = (int)0; j < (int)i; j++) ans[v[j].second] = 1;
      for (int j = (int)i; j < (int)N; j++) ans[v[j].second] = 2;
      break;
    }
    if (yep)
      for (int i = (int)0; i < (int)N; i++) printf("%d ", ans[i]);
    else
      printf("-1");
    printf("\n");
  }
  return 0;
}
