#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 100005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-4
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
inline ll rd() {
ll x = 0;
char c = getchar();
bool f = false;
while (!isdigit(c)) {
if (c == '-') f = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f ? -x : x;
} ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; } /*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1; y = 0; return a;
}
ans = exgcd(b, a%b, x, y);
ll t = x; x = y; y = t - a / b * y;
return ans;
}
*/ int T;
int n;
struct node {
int l, r;
bool operator<(const node&rhs)const {
if (l < rhs.l)return true;
if (l > rhs.l)return false;
if (l == rhs.l)return r < rhs.r;
}
}line[maxn];
int l[maxn], r[maxn]; int main() {
//ios::sync_with_stdio(0);
rdint(T);
while (T--) {
rdint(n);
for (int i = 1; i <= n; i++) {
rdint(l[i]); rdint(r[i]);
line[i].l = l[i]; line[i].r = r[i];
}
sort(line + 1, line + 1 + n);
bool fg = false;
int R = -1;
for (int i = 1; i <= n; i++) {
if (i == 1)R = line[i].r;
if (line[i].l > R) {
fg = true; break;
}
else R = max(R, line[i].r);
}
if (!fg) {
cout << -1 << endl;
}
else {
for (int i = 1; i <= n; i++) {
if (r[i] <= R) {
cout << 1 << ' ';
}
else cout << 2 << ' ';
}
cout << endl;
}
}
return 0;
}

最新文章

  1. webservice jsonp格式调用
  2. 移动端H5页面的最佳终端适配之Flexible
  3. webstrom 中启用emmet插件的方法
  4. Java学习-018-EXCEL 文件写入实例源代码
  5. HDU5534--Partial Tree (完全背包)
  6. 基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:4.安装Oracle RAC FAQ-4.4.无法图形化安装Grid Infrastructure
  7. Careercup - Facebook面试题 - 6321181669982208
  8. simplexml 使用实例
  9. C实现二叉树(模块化集成,遍历的递归与非递归实现)
  10. Content-Type boundary 问题
  11. delphi中panel控件应用
  12. 【笔记】Kali linux的安装 和 一些使用前的准备工作(原创+转载)
  13. Deap Learning (吴恩达) 第一章深度学习概论 学习笔记
  14. .net c#将数据库数据对象转换为实体值对象
  15. 对const的总结与思考
  16. 科学计算和可视化(numpy及matplotlib学习笔记)
  17. Mysql必知必会 第三章 使用Mysql
  18. Java多线程编程核心技术(三)多线程通信
  19. PYMySQL的注册功能的实现
  20. 上海线下技术交流(AA制)

热门文章

  1. 类型:.net;问题:ASP.NET路由;结果:ASP.NET 路由 .NET Framework 4
  2. leetcode241
  3. 简单cpu web flask mysql
  4. URL操作
  5. 分布式锁1 Java常用技术方案【转载】
  6. Blender 基础 骨架-02 骨架的各种呈现方式
  7. ZXing开发详解
  8. wpf 窗口打开后默认设置控件焦点
  9. NPOI操作之一EXCEL数据导入数据库
  10. SSH (Struts2+Spring3.0+Hibernate3)框架(一) 理论