#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
const int mxN = 2e5 + 10;
ifstream cin("2sat.in");
ofstream cout("2sat.out");
vector<int> adj[mxN+1], rev[mxN+1], order;
int visited[mxN+1], compID[mxN+1], sol[mxN+1], nrComp, n , m ;
void DFS1(int node)
{
visited[node] = true;
for(auto it : adj[node])
if(!visited[it])
DFS1(it);
order.push_back(node);
}
void DFS2(int node)
{
compID[node] = nrComp;
visited[node] = true;
for(auto it : rev[node])
if(!visited[it])
DFS2(it);
}
int main()
{
cin >> n >> m;
for(int i = 1;i<=m;i++)
{
int a, b;
cin >> a >> b;
int A = 2 * abs(a) + (a > 0);
int B = 2 * abs(b) + (b > 0);
adj[A^1].push_back(B);
adj[B^1].push_back(A);
rev[A].push_back(B^1);
rev[B].push_back(A^1);
}
for(int i = 1;i<=2*n+1;i++)
if(!visited[i])
DFS1(i);
fill(visited+1,visited+2*n+2,0);
reverse(order.begin(),order.end());
for(auto it : order)
if(!visited[it])
nrComp++, DFS2(it);
bool hasSolution = true;
for(int i = 1;i<=n;i++)
if(compID[2 * i + 1] == compID[2 * i])
hasSolution = false;
if(!hasSolution)
{
cout << -1 << '\n';
return 0;
}
for(int i = 1;i<=n;i++)
cout << (compID[2 * i + 1] > compID[2 * i]) << ' ';
return 0;
}