#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, next;
};
edge e[400005];
int head[200005];
int vis[200005];
int n, m;
int flag;
void dfs(int cur, int tag) {
  if (flag) return;
  if (!vis[cur])
    vis[cur] = tag;
  else {
    if (vis[cur] != tag) flag = 1;
    return;
  }
  for (int i = head[cur]; i != 0; i = e[i].next) {
    if (tag == 1)
      dfs(e[i].to, 2);
    else
      dfs(e[i].to, 1);
  }
}
int main() {
  scanf("%d %d", &n, &m);
  int t1, t2;
  for (int i = 1; i <= 2 * m; i += 2) {
    scanf("%d %d", &t1, &t2);
    e[i].to = t2;
    e[i].next = head[t1];
    head[t1] = i;
    e[i + 1].to = t1;
    e[i + 1].next = head[t2];
    head[t2] = i + 1;
  }
  dfs(1, 1);
  if (flag)
    printf("NO\n");
  else {
    printf("YES\n");
    for (int i = 1; i <= 2 * m; i += 2) {
      if (vis[e[i].to] == 1)
        printf("1");
      else
        printf("0");
    }
  }
  return 0;
}
