#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, a[N], b[N], l[N], r[N];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    bool flag = false;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d%d", l + i, r + i), a[i] = i;
    sort(a + 1, a + 1 + n,
         [](int x, int y) { return l[x] == l[y] ? r[x] < r[y] : l[x] < l[y]; });
    for (int i = 1, R = 0; i <= n; ++i)
      if (i == 1)
        R = r[a[i]];
      else if (l[a[i]] > R) {
        for (int j = 1; j <= n; ++j) b[a[j]] = j < i ? 1 : 2;
        flag = true;
        break;
      } else
        R = max(R, r[a[i]]);
    if (flag) {
      for (int i = 1; i <= n; ++i) printf("%d ", b[i]);
      puts("");
    } else
      puts("-1");
  }
  return 0;
}
