//
// Created by Xiuyuan Cao on 2023/2/22.
//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <limits>
using namespace std;
typedef long long ll;
ll mod=1e9+7;
bool check(vector<int>& segment,vector<int>& res,vector<vector<int>>& points){
int countRed=0;
int countBlue=0;
for(int i=0;i<points.size();i++){
if(points[i][0]>=segment[0]&&points[i][0]<=segment[1]){
if(res[points[i][1]]==1){
countBlue++;
}
else{
countRed++;
}
}
}
return abs(countBlue-countRed)<=1;
}
void solve(){
int n,m;
cin>>n;
cin>>m;
vector<vector<int>> points(n);
for(int i=0;i<n;i++){
int x;
cin>>x;
points[i]={x,i};
}
auto cmp=[](vector<int> p1,vector<int> p2){return p1[0]<p2[0];};
sort(points.begin(),points.end(),cmp);
vector<vector<int>> segments(m);
for(int i=0;i<m;i++){
int l,r;
cin>>l;
cin>>r;
segments[i]={l,r};
}
vector<int> res(n);
for(int i=0;i<n;i++){
res[points[i][1]]=(1-i%2);
}
for(vector<int> segment:segments){
if(check(segment,res,points)==false){
cout<<-1<<endl;
return;
}
}
for(int i:res){
cout<<i<<" ";
}
}
int main(){
solve();
}
102B - Sum of Digits | 707A - Brain's Photos |
1331B - Limericks | 305B - Continued Fractions |
1165B - Polycarp Training | 1646C - Factorials and Powers of Two |
596A - Wilbur and Swimming Pool | 1462B - Last Year's Substring |
1608B - Build the Permutation | 1505A - Is it rated - 2 |
169A - Chores | 765A - Neverending competitions |
1303A - Erasing Zeroes | 1005B - Delete from the Left |
94A - Restoring Password | 1529B - Sifid and Strange Subsequences |
1455C - Ping-pong | 1644C - Increase Subarray Sums |
1433A - Boring Apartments | 1428B - Belted Rooms |
519B - A and B and Compilation Errors | 1152B - Neko Performs Cat Furrier Transform |
1411A - In-game Chat | 119A - Epic Game |
703A - Mishka and Game | 1504C - Balance the Bits |
988A - Diverse Team | 1312B - Bogosort |
1616B - Mirror in the String | 1660C - Get an Even String |