#include <bits/stdc++.h>
using namespace std;
const long long N = (long long)(2e5 + 1);
bool bipartite = true;
vector<long long> colour;
vector<long long> adj[N];
vector<long long> visited;
void dfs(long long node, long long par, long long col) {
  visited[node] = 1;
  colour[node] = col;
  for (auto it : adj[node]) {
    if (!visited[it])
      dfs(it, node, !col);
    else if (it != par and colour[it] == colour[node])
      bipartite = false;
  }
}
signed main() {
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, long long>> edges;
  colour = vector<long long>(n, -1);
  visited = vector<long long>(n, 0);
  for (long long i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    u--, v--;
    adj[v].push_back(u);
    adj[u].push_back(v);
    edges.push_back({u, v});
  }
  dfs(0, -1, 0);
  if (!bipartite) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  for (long long i = 0; i < m; i++) {
    long long ele1 = edges[i].first;
    long long ele2 = edges[i].second;
    cout << (colour[ele1] < colour[ele2]);
  }
  return 0;
}
