#include <bits/stdc++.h>
using namespace std;
void sxseven();
signed main() {
  cin.tie(0);
  cout.tie(0);
  sxseven();
  return 0;
}
vector<long long> a[200001], b[200001], e[200001];
string s;
long long c[200001], d[200001];
void bfs(long long fa, long long n) {
  c[fa] = n;
  for (long long i = 0; i < a[fa].size(); ++i) {
    if (e[fa][i] == 1)
      d[b[fa][i]] = n - 1;
    else
      d[b[fa][i]] = 2 - n;
  }
  n = 3 - n;
  for (long long i = 0; i < a[fa].size(); ++i) {
    if (!c[a[fa][i]])
      bfs(a[fa][i], n);
    else if (c[a[fa][i]] == n)
      continue;
    else {
      cout << "NO";
      exit(0);
    }
  }
}
void sxseven() {
  long long n, m, u, v;
  cin >> n >> m;
  for (long long i = 1; i <= m; ++i) {
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
    b[u].push_back(i);
    b[v].push_back(i);
    e[u].push_back(1);
    e[v].push_back(-1);
  }
  bfs(1, 1);
  for (long long i = 1; i <= m; ++i) {
    if (d[i] == 0)
      s += '0';
    else
      s += '1';
  }
  cout << "YES\n" << s;
}
