#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int color[N];
vector<int> g[N];
vector<pair<int, int> > edge;
int bip;
void dfs(int u, int c) {
  color[u] = c;
  for (auto to : g[u]) {
    if (color[to] == -1)
      dfs(to, 1 - c);
    else {
      if (color[to] == color[u]) {
        bip = 0;
        return;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  memset(color, -1, sizeof(color));
  int n, m;
  cin >> n >> m;
  int x, y;
  bip = 1;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
    edge.push_back({x, y});
  }
  dfs(1, 1);
  if (bip == 0) {
    cout << "NO" << endl;
    return 0;
  }
  string ans = "";
  for (int i = 0; i < m; i++) {
    x = color[edge[i].first];
    y = color[edge[i].second];
    if (x > y)
      ans += '0';
    else
      ans += '1';
  }
  cout << "YES" << endl;
  cout << ans << endl;
  return 0;
}
