#include <bits/stdc++.h>
using namespace std;
vector<long long int> a[200007], idx[200007];
long long int vis[200007], lvl[200007], f, p[200007], q[200007], ans[200007];
void dfs(long long int u) {
  vis[u] = 1;
  long long int i;
  for (i = 0; i < a[u].size(); i++) {
    long long int v = a[u][i], x = idx[u][i];
    if (!vis[v]) {
      lvl[v] = lvl[u] + 1;
      if (lvl[u] % 2) {
        if (p[x] == v) ans[x] = 1;
      } else {
        if (p[x] == u) ans[x] = 1;
      }
      dfs(v);
    } else if (lvl[v] % 2 == lvl[u] % 2)
      f = 1;
    else {
      if (lvl[u] % 2) {
        if (p[x] == v) ans[x] = 1;
      } else {
        if (p[x] == u) ans[x] = 1;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, m, i;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    long long int x, y;
    cin >> x >> y;
    p[i] = x;
    q[i] = y;
    a[x].push_back(y);
    a[y].push_back(x);
    idx[x].push_back(i);
    idx[y].push_back(i);
  }
  lvl[1] = 1;
  dfs(1);
  if (f) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  for (i = 0; i < m; i++) cout << ans[i];
  cout << endl;
  return 0;
}
