#include <bits/stdc++.h>
using namespace std;
struct t {
  int x;
  int y;
  int poz;
} v[100001];
t ras[100001];
bool f[100001];
short int tont[100001];
bool comp(t a, t b) { return (a.x < b.x || a.x == b.x && a.y < b.y); }
int main() {
  int q, n, i, el, j, f1x, f1y, nr1, nr2;
  cin >> q;
  int k = 0;
  for (i = 1; i <= q; ++i) {
    cin >> n;
    for (j = 1; j <= n; ++j) {
      cin >> v[j].x >> v[j].y;
      v[j].poz = j;
    }
    sort(v + 1, v + n + 1, comp);
    f1x = v[1].x;
    f1y = v[1].y;
    tont[v[1].poz] = 1;
    nr1 = 1;
    nr2 = 0;
    for (j = 2; j <= n; ++j) {
      if (v[j].x > f1y) {
        nr2++;
        tont[v[j].poz] = 2;
      } else {
        f1y = max(f1y, v[j].y);
        tont[v[j].poz] = 1;
        nr1++;
      }
    }
    if (nr1 == 0 || nr2 == 0) f[i] = 1;
    for (j = 1; j <= n; ++j) {
      ras[++k].x = i;
      ras[k].y = tont[j];
    }
  }
  for (i = 1; i <= k; ++i) {
    if (f[ras[i].x] == 0) {
      el = ras[i].x;
      while (ras[i].x == el) {
        cout << ras[i].y << " ";
        i++;
      }
      cout << "\n";
      i--;
    } else {
      el = ras[i].x;
      while (ras[i].x == el) i++;
      cout << "-1\n";
      i--;
    }
  }
  return 0;
}
