#include <bits/stdc++.h>
using namespace std;
int visited[512345] = {0};
int main() {
  int V, E;
  cin >> V >> E;
  vector<int> colors = vector<int>(V + 1);
  vector<pair<int, int>> es = vector<pair<int, int>>(E);
  vector<vector<int>> graph = vector<vector<int>>(V + 1);
  for (int i = 0; i < E; ++i) {
    int a, b;
    cin >> a >> b;
    es[i] = make_pair(a, b);
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  queue<pair<int, int>> q;
  q.push(make_pair(1, 0));
  visited[1] = 1;
  colors[1] = 0;
  while (!q.empty()) {
    pair<int, int> curr = q.front();
    q.pop();
    for (auto viz : graph[curr.first]) {
      if (!visited[viz]) {
        visited[viz] = 1;
        colors[viz] = !colors[curr.first];
        q.push(make_pair(viz, (curr.second + 1) % 2));
      } else if (colors[viz] != (curr.second + 1) % 2) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  for (auto e : es) {
    if (colors[e.first] == 0) {
      cout << 1;
    } else {
      cout << 0;
    }
  }
  cout << endl;
}
