#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > dupg;
vector<char> color;
bool dfs(int u, char col) {
  color[u] = col;
  for (int v : dupg[u]) {
    if (color[v] == col) {
      return false;
    }
    if (color[v] == 'u') {
      char newcol;
      col == 'o' ? newcol = 'i' : newcol = 'o';
      if (!dfs(v, newcol)) return false;
    }
  }
  return true;
}
void solve() {
  long long m, n;
  long long i, j;
  cin >> n >> m;
  dupg.resize(n);
  vector<pair<int, int> > edge(m);
  long long x, y;
  for (i = (0); i < (m); i++) {
    cin >> x >> y;
    x--, y--;
    edge[i] = make_pair(x, y);
    dupg[x].push_back(y);
    dupg[y].push_back(x);
  }
  color.resize(n, 'u');
  for (i = (0); i < (n); i++) {
    if (color[i] == 'u') {
      if (!dfs(i, 'o')) {
        cout << "NO\n";
        return;
      }
    }
  }
  string ans;
  ans.resize(m, '1');
  for (i = (0); i < (m); i++) {
    x = edge[i].first;
    if (color[x] != 'i') {
      ans[i] = '0';
    }
  }
  cout << "YES\n";
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
