#include

#include

#include

using namespace std;

vector<pair<pair<int, int>, int> > intervals;

int T, n, L, R;

int color[100010];

int main()

{

ios_base::sync_with_stdio(false);

cin.tie(NULL);

cin>>T;

while(T–)

{

cin>>n;

intervals.clear();

for(int i = 0; i < n; ++i)

{

cin>>L>>R;

intervals.push_back(make_pair(make_pair(L, R), i));

}

sort(intervals.begin(), intervals.end());

int max_e0 = 0;

int max_e1 = 0;

```
for(auto p : intervals)
{
int s = p.first.first;
int e = p.first.second;
int label = p.second;
if(max_e0 >= max_e1)
{
color[label] = 1;
max_e1 = max(max_e1, e);
}
else
{
color[label] = 0;
max_e0 = max(max_e0, e);
}
}
for(int i = 0; i < n; ++i)
cout<<color[i];
cout<<endl;
}
```

}

/*

after challenge end

i tried to understand some of problem by looking at

soln of others but i am not able to understand what logic they have used

same goes to many problems!

*/