#include <bits/stdc++.h>
using namespace std;
long long u[200001], v[200001];
int visit[200001];
vector<long long> vec[200001];
int main() {
  int check = 0;
  long long n, m;
  scanf("%lld %lld", &n, &m);
  long long i, j;
  for (i = 0; i < m; i++) {
    scanf("%lld %lld", &u[i], &v[i]);
    vec[u[i]].push_back(v[i]);
    vec[v[i]].push_back(u[i]);
  }
  visit[1] = 1;
  queue<long long> q;
  q.push(1);
  while (!q.empty()) {
    long long now = q.front();
    q.pop();
    long long p;
    if (visit[now] == 1)
      p = 2;
    else
      p = 1;
    for (i = 0; i < vec[now].size(); i++) {
      long long next = vec[now][i];
      if (!visit[next]) {
        visit[next] = p;
        q.push(next);
      }
      if (visit[next] == visit[now]) {
        check = 1;
        break;
      }
    }
    if (check) break;
  }
  if (check) {
    printf("NO");
    return 0;
  } else {
    printf("YES\n");
    for (i = 0; i < m; i++)
      if (visit[u[i]] == 1 && visit[v[i]] == 2)
        printf("1");
      else
        printf("0");
  }
}
