func_code_string: #include <bits/stdc++.h>   using namespace std;   inline int read() {     int ch = getchar(), f = 0;     int x = 0;     while (ch <  0  || ch >  9 ) {       f |= ch ==  - ;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return f ? -x : x;   }   struct eric {     int to, next, v;   } edge[10005 << 4];   int head[10005], size = 1;   int n, m;   int dis[10005], out[10005 << 4], vis[10005], used[10005], num[10005];   inline void add(int x, int y, int z) {     edge[++size].to = y;     edge[size].v = z;     edge[size].next = head[x];     head[x] = size;   }   queue<int> que;   int ined[10005];   void dfs1(int pos) {     vis[pos] = 1;     for (int i = head[pos]; i; i = edge[i].next) {       int v = edge[i].to;       if (edge[i].v < 0 || vis[v]) continue;       dfs1(v);     }   }   void dfs2(int pos) {     used[pos] = 1;     for (int i = head[pos]; i; i = edge[i].next) {       int v = edge[i].to;       if (edge[i].v > 0 || used[v]) continue;       dfs2(v);     }   }   inline bool ok(int x, int y) { return used[x] && used[y] && vis[x] && vis[y]; }   inline void SPFA(int s) {     for (int i = 1; i <= n; i++) dis[i] = -1000000007 / 10;     dis[s] = 0;     que.push(s);     ined[s] = 1;     while (!que.empty()) {       int u = que.front();       que.pop();       ined[u] = 0;       for (int i = head[u]; i; i = edge[i].next) {         int v = edge[i].to;         if (dis[v] < dis[u] + edge[i].v && ok(u, v)) {           dis[v] = dis[u] + edge[i].v;           if (!ined[v]) ined[v] = 1, que.push(v), num[v]++;         }       }       if (num[u] >= n) {         puts( No );         exit(0);       }     }   }   int main() {     n = read(), m = read();     for (int i = 1, x, y; i <= m; i++)       x = read(), y = read(), add(x, y, 1), add(y, x, -2);     dfs1(1);     dfs2(n);     SPFA(1);     for (int u = 1; u <= n; u++) {       for (int i = head[u]; i; i = edge[i].next) {         int v = edge[i].to;         if (!ok(u, v)) {           out[i >> 1] = 1;           continue;         }         out[i >> 1] = abs(dis[v] - dis[u]);         if (out[i >> 1] > 2) {           puts( No );           return 0;         }       }     }     puts( Yes );     for (int i = 1; i <= m; i++) printf( %d n , out[i]);     return 0;   }   