#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k[100000], a = 0, l = -15, r = 0, x, y, s;
  pair<int, int> c[100000];
  cin >> s;
  for (int h = 0; h < s; h++) {
    cin >> n;
    for (int q = 0; q < n; q++) {
      cin >> x >> y;
      k[q] = x;
      c[q] = make_pair(x, y);
    }
    sort(c, c + n);
    r = c[0].second;
    for (int j = 1; j < n; j++) {
      r = max(r, c[j - 1].second);
      if (r < c[j].first) {
        a = c[j].first;
        l = 14;
        break;
      }
    }
    if (l < 0) {
      cout << -1;
    } else {
      for (int w = 0; w < n; w++) {
        if (k[w] < a) {
          cout << 1 << " ";
        }
        if (k[w] >= a) {
          cout << 2 << " ";
        }
      }
    }
    l = -15;
    a = 0;
    r = 0;
    cout << endl;
  }
  return 0;
}
