import
java.util.ArrayList;
import
java.util.Arrays;
import
java.util.Collections;
import
java.util.Comparator;
import
java.util.List;
public
class
Gfg {
public
static
void
main(String[] args)
{
List<Pair> v = Arrays.asList(
new
Pair(
2
,
8
),
new
Pair(
3
,
4
),
new
Pair(
5
,
8
),
new
Pair(
9
,
10
));
int
n = v.size();
printAnswer(v, n);
}
static
class
Pair {
int
first;
int
second;
public
Pair(
int
first,
int
second)
{
this
.first = first;
this
.second = second;
}
}
static
class
Trio {
int
first;
int
second;
int
third;
public
Trio(
int
first,
int
second,
int
third)
{
this
.first = first;
this
.second = second;
this
.third = third;
}
}
static
void
printAnswer(List<Pair> v,
int
n)
{
List<Trio> vec =
new
ArrayList<>();
for
(
int
i =
0
; i < n; i++) {
vec.add(
new
Trio(v.get(i).first,
v.get(i).second, i));
}
vec.sort(
new
Comparator<Trio>() {
@Override
public
int
compare(Trio o1, Trio o2)
{
return
o1.first - o2.first;
}
});
int
[] res =
new
int
[n];
Arrays.fill(res,
2
);
int
maxR = vec.get(
0
).second;
res[vec.get(
0
).third] =
1
;
boolean
ok =
false
;
for
(
int
i =
1
; i < n; i++) {
if
(maxR >= vec.get(i).first) {
res[vec.get(i).third]
= res[vec.get(i -
1
).third];
maxR = Math.max(maxR, vec.get(i).second);
}
else
{
ok =
true
;
break
;
}
}
if
(ok) {
for
(
int
x : res) {
System.out.print(x +
" "
);
}
System.out.println();
}
else
{
System.out.println(
"Not possible"
);
}
}
}