#include <bits/stdc++.h>
using namespace std;
vector<int> vc[200005];
vector<pair<int, int> > ed;
map<int, int> deg, mark;
int bfs(int node) {
  queue<int> q;
  int i, j, k, l, u, v, fl = 1;
  q.push(node);
  deg[node] = 1;
  while (q.size()) {
    u = q.front();
    mark[u] = 1;
    int d = deg[u];
    q.pop();
    for (i = 0; i < vc[u].size(); i++) {
      v = vc[u][i];
      if (mark[v] == 0) {
        if (d == 1) {
          if (deg[v] == 1)
            return 0;
          else
            deg[v] = 2;
        } else if (d == 2) {
          if (deg[v] == 2)
            return 0;
          else
            deg[v] = 1;
        }
        q.push(v);
      }
    }
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b, c, d, e, i, j, n, t, tc, f = 0, m;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    ed.push_back({a, b});
    vc[a].push_back(b);
    vc[b].push_back(a);
  }
  if (bfs(ed[0].first))
    cout << "YES\n";
  else {
    cout << "NO\n";
    return 0;
  }
  for (i = 0; i < m; i++) {
    if (deg[ed[i].first] == 1 && deg[ed[i].second] == 2)
      cout << '0';
    else if (deg[ed[i].first] == 2 && deg[ed[i].second] == 1)
      cout << '1';
  }
  return 0;
}
