#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 0, n = 0, l = 0, r = 0, flag = 0, p = 0, my = 0;
  cin >> t;
  while (t--) {
    cin >> n;
    vector<tuple<int, int, int> > v;
    for (int i = 0; i < n; ++i) {
      cin >> l >> r;
      v.emplace_back(l, r, i);
    }
    sort(v.begin(), v.end());
    vector<int> res(n);
    flag = 0;
    p = 1;
    my = 0;
    for (auto i : v) {
      int x, y, z;
      tie(x, y, z) = i;
      if (my < x) {
        p ^= 1;
        ++flag;
      }
      res[z] = p + 1;
      my = max(my, y);
    }
    if (flag == 1)
      cout << "-1";
    else {
      for (auto i : res) {
        cout << i << " ";
      }
    }
    cout << endl;
  }
}
