wa第四个点,目测塔扬写错了
#include<iostream>
#include<cstdio>
#include<stack>
#define ll long long
#define N 1000005
using namespace std;
struct edge
{
ll q,z,xg;
}ed[N<<2];
stack <ll>q;
ll n,m,dd[N<<1],db=1,sy[N<<1],dfn[N<<1],low[N<<1],cnt,tot;
void fjq(ll q,ll z){
ed[db].q=q,ed[db].z=z,ed[db].xg=dd[q],dd[q]=db++;
}
bool vis[N<<1];
void dfs(ll root){
q.push(root);
dfn[root]=low[root]=++cnt;
vis[root]=1;
for(ll i=dd[root];i;i=ed[i].xg){
ll to=ed[i].z;
if(!dfn[to]){
dfs(to);
low[root]=min(low[root],low[to]);
}
else if(!vis[to])low[root]=min(low[root],dfn[to]);
}
if(dfn[root]==low[root]){
tot++;
while(q.top()!=root){
ll ddd=q.top();
sy[ddd]=tot;
q.pop();
}
sy[root]=tot;
q.pop();
}
}
int main(){
scanf("%lld%lld",&n,&m);
int a,b;
ll x,y;
for(ll i=1;i<=m;i++){
scanf("%lld%d%lld%d",&x,&a,&y,&b);
fjq(x+(a^1)*n,y+b*n),fjq(y+(b^1)*n,x+a*n);
}
for(ll i=1;i<=2*n;i++){
if(!dfn[i])
dfs(i);
}
for(ll i=1;i<=n;i++){
cout<<sy[i]<<' '<<sy[i+n]<<endl;
if(sy[i]==sy[i+n]){
printf("IMPOSSIBLE");
return 0;
}
}
printf("POSSIBLE\n");
for(ll i=1;i<=n;i++){
if(sy[i]>sy[i+n]){
printf("1 ");
}
else printf("0 ");
}
return 0;
}