#include <bits/stdc++.h>
using namespace std;
int main() {
  ifstream fin("input.txt", ios::in);
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  cout << setprecision(10);
  cout << fixed;
  int t;
  cin >> t;
  int in1[200010];
  int in2[200010];
  while (t--) {
    int n;
    cin >> n;
    set<pair<int, int> > d, ans;
    for (int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      in1[i] = a;
      in2[i] = b;
      d.insert({a, b});
    }
    int l = d.begin()->second;
    int i = 1;
    int f = 0;
    for (set<pair<int, int> >::iterator it = d.begin(); it != d.end(); it++) {
      if (it == d.begin()) continue;
      if (it->first <= l) {
        l = max(l, it->second);
        i++;
      } else {
        f = 1;
        break;
      }
    }
    if (f == 0)
      cout << -1 << endl;
    else {
      for (set<pair<int, int> >::iterator it = d.begin(); it != d.end(); it++) {
        if (i == 0) break;
        ans.insert({it->first, it->second});
        i--;
      }
      for (int i = 0; i < n; i++) {
        if (ans.find({in1[i], in2[i]}) == ans.end())
          cout << 1 << " ";
        else
          cout << 2 << " ";
      }
      cout << endl;
    }
  }
}
