#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
typedef struct node {
  int l, r, th;
} Node;
vector<Node> v;
vector<int> res;
int out[maxn];
bool cmp(Node a, Node b) { return a.l < b.l; }
int main() {
  int T, n, l, r;
  Node tmp;
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%d%d", &l, &r);
      tmp.l = l;
      tmp.r = r;
      tmp.th = i;
      v.push_back(tmp);
    }
    sort(v.begin(), v.end(), cmp);
    int p1 = -1, g = 1, cot = 0;
    for (int i = 0; i < v.size(); i++) {
      l = v[i].l;
      r = v[i].r;
      if (l > p1) {
        cot++;
        g = 3 - g;
        res.push_back(g);
        p1 = r;
      } else {
        res.push_back(g);
        p1 = max(p1, r);
      }
    }
    if (cot >= 2) {
      for (int i = 0; i < v.size(); i++) out[v[i].th] = res[i];
      for (int i = 1; i <= n; i++) {
        if (i > 1) putchar(' ');
        printf("%d", out[i]);
      }
    } else
      printf("-1");
    putchar('\n');
    v.clear();
    res.clear();
  }
  return 0;
}
