#include <bits/stdc++.h>
using namespace std;
vector<int> g[1000001];
bool mark[1000001], color[1000001];
bool bfs() {
  queue<int> q;
  q.push(1);
  color[1] = 1;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    mark[v] = 1;
    for (int u : g[v]) {
      if (!mark[u]) {
        q.push(u);
        color[u] = !color[v];
      } else if (color[u] == color[v])
        return 0;
    }
  }
  return 1;
}
int main() {
  int n, m, a, b;
  vector<pair<int, int>> edges;
  cin >> n >> m;
  while (m--) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
    edges.push_back({a, b});
  }
  if (!bfs())
    cout << "NO\n";
  else {
    cout << "YES\n";
    for (auto i : edges) cout << (color[i.first] > color[i.second]);
    cout << "\n";
  }
}
