#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long N = 200005;
vector<long long> vis(N);
vector<vector<long long>> adj(N);
void dfs(long long v) {
  vis[v] = 1;
  for (auto i : adj[v]) {
    if (!vis[i]) {
      dfs(i);
    }
  }
  return;
}
bool isPrime(long long n) {
  if (n < 2) return false;
  for (long long i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
long long factorial(long long n) {
  return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
long long power(long long x, long long y) {
  long long res = 1;
  x = x;
  while (y > 0) {
    if (y & 1) res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res % mod;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); }
long long max(long long a, long long b) {
  long long ans = a > b ? a : b;
  return ans;
}
long long min(long long a, long long b) {
  long long ans = a < b ? a : b;
  return ans;
}
long long root(long long a[], long long i) {
  while (a[i] != i) {
    a[i] = a[a[i]];
    i = a[i];
  }
  return i;
}
void unionn(long long a[], long long i, long long j) {
  long long root_i = root(a, i);
  long long root_j = root(a, j);
  a[root_i] = root_j;
  return;
}
void fun() {}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  fun();
  long long tt = 1;
  cin >> tt;
  while (tt--) {
    long long c1 = 0, c2 = 0;
    long long n;
    cin >> n;
    map<long long, pair<long long, long long>> m;
    map<pair<long long, long long>, long long> m1;
    long long maxx = 0;
    vector<pair<long long, long long>> a(n);
    for (long long i = 0; i < n; i++) {
      cin >> a[i].first >> a[i].second;
      m[i] = a[i];
    }
    sort(a.begin(), a.end());
    for (long long i = 0; i < n; i++) {
      if (!c1) {
        m1[a[i]] = 1;
        c1 = 1;
        maxx = max(maxx, a[i].second);
      } else {
        if (a[i].first > maxx) {
          if (m1[a[i - 1]] == 1) {
            m1[a[i]] = 2;
            c2 = 1;
          } else {
            m1[a[i]] = 1;
          }
          maxx = max(maxx, a[i].second);
        } else {
          m1[a[i]] = m1[a[i - 1]];
          maxx = max(maxx, a[i].second);
        }
      }
    }
    if (!c2) {
      cout << "-1"
           << "\n";
      continue;
    }
    for (long long i = 0; i < n; i++) cout << m1[m[i]] << " ";
    cout << "\n";
  }
  return 0;
}
