#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 239;
const long long INFL = 1e18 + 239;
const int MAXN = 2e5 + 1;
const int MOD = 998244353;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    vector<pair<pair<int, int>, int>> v(n);
    for (int i = 0; i < n; ++i) {
      cin >> v[i].first.first >> v[i].first.second;
      v[i].second = i;
    }
    sort(v.begin(), v.end());
    int rmx = -1, cnt = 0;
    vector<int> ans(n, 2);
    for (int i = 0; i < n; ++i) {
      if (rmx != -1 && v[i].first.first > rmx) break;
      rmx = max(v[i].first.second, rmx);
      ans[v[i].second] = 1;
      cnt++;
    }
    if (cnt == n) {
      cout << "-1\n";
      continue;
    }
    for (int i = 0; i < n; ++i) cout << (i ? " " : "") << ans[i];
    cout << "\n";
  }
  return 0;
}
