#include<bits/stdc++.h> #define rei register int #define N 4000005 usingnamespace std; typedeflonglong LL; typedefunsignedlonglong ull;
int n, m, dfn[N], low[N], cnt, co[N], st[N], top, col; vector<int> g[N];
structedge { int v, nxt; } e[N];
template <typename T> inlinevoidread(T &x) { x = 0; int f = 1; char ch = getchar(); while (!isdigit(ch)) {if (ch == '-') f = -f; ch = getchar();} while (isdigit(ch)) {x = x * 10 + ch - 48; ch = getchar();} x *= f; }
inlinevoidTarjan(int x) { dfn[x] = low[x] = ++cnt; st[++top] = x; for (rei i = 0; i < g[x].size(); i++) { int v = g[x][i]; if (!dfn[v]) { Tarjan(v); low[x] = min(low[x], low[v]); } elseif (!co[v]) low[x] = min(low[x], dfn[v]); } if (low[x] == dfn[x]) { co[x] = ++col; while (st[top] != x) { co[st[top]] = col; top--; } top--; } }
intmain() { read(n); read(m); for (rei i = 1; i <= m; i++) { int j, a, k, b; read(j); read(a); read(k); read(b); g[j + n * (a & 1)].push_back(k + n * (b ^ 1)); g[k + n * (b & 1)].push_back(j + n * (a ^ 1)); } for (rei i = 1; i <= n * 2; i++) if (!dfn[i]) Tarjan(i); for (rei i = 1; i <= n; i++) { if (co[i] == co[i + n]) { printf("IMPOSSIBLE\n"); return0; } } printf("POSSIBLE\n"); for (rei i = 1; i <= n; i++) { int res = co[i] < co[i + n]; printf("%d ", res); } return0; }