#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int ans[N];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, mx = 0;
    scanf("%d", &n);
    vector<pair<int, int> > vec, arr(n);
    for (int i = 0; i < n; i++) {
      int l, r;
      scanf("%d", &l);
      scanf("%d", &r);
      vec.push_back({l, 0});
      vec.push_back({r, 1});
      arr[i] = {l, r};
    }
    sort((vec).begin(), (vec).end());
    int s = 0, cnt = 0, sta = 0, end = 0;
    for (int i = 0; i < int((vec).size()); i++) {
      if (vec[i].second == 0) {
        s++;
        if (!sta) sta = vec[i].first;
      } else {
        s--;
        if (s == 0) {
          cnt++;
          if (!end) end = vec[i].first;
        }
      }
    }
    if (cnt < 2) {
      printf("-1\n");
      continue;
    }
    for (int i = 0; i < n; i++) {
      if (arr[i].first >= sta && arr[i].second <= end)
        printf("1 ");
      else
        printf("2 ");
    }
    printf("\n");
  }
}
