#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, ans[N], a, b, mx;
pair<int, pair<int, int> > arr[N];
bool can;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
      ans[i] = 1;
      scanf("%d%d", &arr[i].first, &arr[i].second.first);
      arr[i].second.second = i;
    }
    sort(arr, arr + n);
    can = false;
    mx = -1;
    for (int i = 0; i < n; i++) {
      if (can) {
        ans[arr[i].second.second] = 2;
        continue;
      }
      if (arr[i].first > mx && mx != -1) {
        ans[arr[i].second.second] = 2;
        can = true;
        continue;
      }
      mx = max(mx, arr[i].second.first);
    }
    if (!can) {
      puts("-1");
      continue;
    }
    for (int i = 0; i < n; i++) {
      if (i) putchar(' ');
      printf("%d", ans[i]);
    }
    puts("");
  }
  return 0;
}
