#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
mt19937 rng(time(NULL));
const int inf = 1e9 + 100;
const long long linf = 2e18;
const long long maxn = 2e5 + 100;
const int mod = 1e9 + 7;
vector<int> g[maxn];
int c[maxn];
bool f = 1;
void dfs(int v, int cl) {
  c[v] = cl;
  for (int i : g[v]) {
    if (c[i] == 0)
      dfs(i, cl == 1 ? 2 : 1);
    else if (c[i] == cl)
      f = 0;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > ans(m);
  for (int i = 0; i < m; ++i) {
    cin >> ans[i].first >> ans[i].second;
    g[ans[i].first - 1].push_back(ans[i].second - 1);
    g[ans[i].second - 1].push_back(ans[i].first - 1);
  }
  for (int i = 0; i < n; ++i)
    if (!c[i]) dfs(i, 1);
  if (f) {
    cout << "YES\n";
    for (auto i : ans) {
      if (c[i.first - 1] == 2)
        cout << 1;
      else
        cout << 0;
    }
  } else
    cout << "NO";
  return 0;
}
