#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
vector<int> g[N];
map<pair<int, int>, int> mem;
bool vis[N], f;
vector<pair<int, int> > ed;
void dfs(int u, int val) {
  vis[u] = 1;
  for (auto v : g[u]) {
    pair<int, int> tmp1 = {u, v}, tmp2 = {v, u};
    if (val == 1) {
      if (mem.find(tmp2) != mem.end())
        f = 1;
      else {
        if (mem.find(tmp1) == mem.end()) mem.insert({tmp1, 1});
      }
    } else {
      if (mem.find(tmp1) != mem.end())
        f = 1;
      else {
        if (mem.find(tmp2) == mem.end()) mem.insert({tmp2, 1});
      }
    }
    if (not vis[v]) dfs(v, val == 1 ? 2 : 1);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v), g[v].push_back(u);
    ed.push_back({u, v});
  }
  f = 0;
  dfs(1, 1);
  if (not f) {
    cout << "YES\n";
    for (auto p : ed) {
      cout << (mem.find(p) == mem.end());
    }
    cout << '\n';
    return 0;
  }
  mem.clear();
  memset(vis, 0, sizeof vis);
  f = 0;
  dfs(1, 2);
  if (not f) {
    cout << "YES\n";
    for (auto p : ed) {
      cout << (mem.find(p) == mem.end());
    }
    cout << '\n';
    return 0;
  }
  cout << "NO\n";
  return 0;
}
