| 128 | } |
| 129 | |
| 130 | public static void main(String[] args) throws Exception { |
| 131 | FastReader in = new FastReader(System.in); |
| 132 | PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); |
| 133 | n = in.nextInt(); |
| 134 | m = in.nextInt(); |
| 135 | for (int i = 1, x1, v1, x2, v2; i <= m; i++) { |
| 136 | x1 = in.nextInt(); |
| 137 | v1 = in.nextInt(); |
| 138 | x2 = in.nextInt(); |
| 139 | v2 = in.nextInt(); |
| 140 | if (v1 == 1 && v2 == 1) { |
| 141 | addEdge(x1 + n, x2); |
| 142 | addEdge(x2 + n, x1); |
| 143 | } else if (v1 == 0 && v2 == 1) { |
| 144 | addEdge(x1, x2); |
| 145 | addEdge(x2 + n, x1 + n); |
| 146 | } else if (v1 == 1 && v2 == 0) { |
| 147 | addEdge(x2, x1); |
| 148 | addEdge(x1 + n, x2 + n); |
| 149 | } else { |
| 150 | addEdge(x1, x2 + n); |
| 151 | addEdge(x2, x1 + n); |
| 152 | } |
| 153 | } |
| 154 | for (int i = 1; i <= n << 1; i++) { |
| 155 | if (dfn[i] == 0) { |
| 156 | // tarjan1(i); |
| 157 | tarjan2(i); |
| 158 | } |
| 159 | } |
| 160 | boolean check = true; |
| 161 | for (int i = 1; i <= n; i++) { |
| 162 | if (belong[i] == belong[i + n]) { |
| 163 | check = false; |
| 164 | break; |
| 165 | } |
| 166 | } |
| 167 | if (check) { |
| 168 | out.println("POSSIBLE"); |
| 169 | for (int i = 1; i <= n; i++) { |
| 170 | if (belong[i] < belong[i + n]) { |
| 171 | out.print("1 "); |
| 172 | } else { |
| 173 | out.print("0 "); |
| 174 | } |
| 175 | } |
| 176 | } else { |
| 177 | out.println("IMPOSSIBLE"); |
| 178 | } |
| 179 | out.flush(); |
| 180 | out.close(); |
| 181 | } |
| 182 | |
| 183 | // 读写工具类 |
| 184 | static class FastReader { |