#include <bits/stdc++.h>
using namespace std;
vector<int> color(200010, -1);
map<int, vector<int> > tab;
void dfs(int node, int step) {
  if (color[node] == -1 or color[node] == step % 2) {
    if (color[node] == step % 2) return;
    color[node] = step % 2;
    for (int i = 0; i < tab[node].size(); i++) {
      dfs(tab[node][i], step + 1);
    }
  } else if (color[node] != step % 2) {
    cout << "NO" << endl;
    exit(0);
  }
}
int main() {
  int n, m;
  vector<int> u, v;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int ut, vt;
    cin >> ut >> vt;
    u.push_back(--ut);
    v.push_back(--vt);
    tab[ut].push_back(vt);
    tab[vt].push_back(ut);
  }
  dfs(0, 0);
  cout << "YES" << endl;
  for (int i = 0; i < m; i++) {
    if (color[u[i]] % 2)
      cout << 0;
    else
      cout << 1;
  }
  return 0;
}
