#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
struct Seg {
  int l, r, id;
  void scan(int _id) {
    scanf("%d%d", &l, &r);
    id = _id;
  }
} s[N];
int p[N];
int cmp(Seg s1, Seg s2) { return s1.r < s2.r; }
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) s[i].scan(i);
    sort(s + 1, s + 1 + n, cmp);
    int mn = 1;
    for (int i = 2; i <= n; ++i) {
      if (s[i].l <= s[mn].r) mn = i;
    }
    if (mn != n) {
      for (int i = 1; i <= mn; ++i) p[s[i].id] = 1;
      for (int i = mn + 1; i <= n; ++i) p[s[i].id] = 2;
      for (int i = 1; i <= n; ++i) printf("%d ", p[i]);
      puts("");
    } else {
      puts("-1");
    }
  }
}
