#include <bits/stdc++.h>
using Point = int64_t;
using Segment = std::pair<Point, Point>;
using Segments = std::vector<Segment>;
auto divide(const Segments &segments_) -> std::vector<bool> {
  auto segments = segments_;
  std::sort(segments.begin(), segments.end());
  auto build_mask = [&segments_](Point divider) {
    std::vector<bool> results(segments_.size());
    std::transform(
        segments_.begin(), segments_.end(), results.begin(),
        [divider](const Segment &segment) { return segment.first < divider; });
    return results;
  };
  Point last = segments.front().second;
  for (auto segment : segments) {
    if (segment.first >= last) {
      return build_mask(last);
    }
    last = std::max(segment.second, last);
  }
  return {};
}
auto main() -> int {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  size_t tests;
  std::cin >> tests;
  for (size_t test = 0; test < tests; ++test) {
    size_t count;
    std::cin >> count;
    auto segments = Segments(count);
    for (auto &[left, right] : segments) {
      std::cin >> left >> right;
      ++right;
    }
    auto results = divide(segments);
    if (results.empty()) {
      std::cout << "-1\n";
    }
    for (auto result : results) {
      std::cout << (result ? 1 : 2) << ' ';
    }
    std::cout << "\n";
  }
  return 0;
}
