#include <bits/stdc++.h>
using namespace std;
long long n, m, x[200010], y[200010], col[200010];
long long ver[400010], Next[400010], head[200010], tot;
inline long long read() {
  long long x = 0, tmp = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') tmp = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + ch - 48;
    ch = getchar();
  }
  return tmp * x;
}
inline void addEdge(long long x, long long y) {
  ver[++tot] = y;
  Next[tot] = head[x];
  head[x] = tot;
}
void dfs(long long x, long long colour) {
  col[x] = colour;
  for (long long i = head[x]; i; i = Next[i]) {
    long long y = ver[i];
    if (col[x] == col[y]) {
      printf("NO\n");
      exit(0);
    }
    if (col[y]) continue;
    dfs(y, 3 - colour);
  }
}
signed main() {
  n = read();
  m = read();
  for (long long i = 1; i <= m; i++) {
    x[i] = read();
    y[i] = read();
    addEdge(x[i], y[i]);
    addEdge(y[i], x[i]);
  }
  dfs(1, 1);
  printf("YES\n");
  for (long long i = 1; i <= m; i++) printf("%lld", 2 - col[x[i]]);
  putchar('\n');
}
