#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
struct pii {
  int l, r, p, v;
} s[maxn];
int ans[maxn];
bool cmp(pii a, pii b) { return a.l < b.l; }
void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int a, b;
    cin >> a >> b;
    s[i] = {a, b, i, 0};
  }
  sort(s + 1, s + 1 + n, cmp);
  s[0] = {0, 0, 0, 0};
  s[n + 1] = {210000, 210000, n + 1, 0};
  int flag = 0;
  int rr = s[1].r;
  for (int i = 2; i <= n; ++i) {
    if (s[i].l > rr) {
      s[i].v = s[i - 1].v ^ 1;
      flag = 1;
    } else {
      s[i].v = s[i - 1].v;
    }
    rr = max(rr, s[i].r);
  }
  if (!flag) {
    cout << -1 << endl;
    return;
  }
  for (int i = 1; i <= n; ++i) ans[s[i].p] = s[i].v;
  for (int i = 1; i <= n; ++i) cout << ans[i] + 1 << " ";
  cout << endl;
}
int main() {
  ios::sync_with_stdio(0);
  int T;
  cin >> T;
  while (T--) solve();
}
