#include <bits/stdc++.h>
using namespace std;
struct Vertex {
  int color = -1;
  list<int> e;
};
const int MAX = 200001;
Vertex vertices[MAX];
int edges[MAX];
bool possible = true;
bool dfs(int n, int color) {
  if (vertices[n].color != -1 && vertices[n].color != color) return false;
  int possible = true;
  if (vertices[n].color == -1) {
    vertices[n].color = color;
    for (auto i = vertices[n].e.begin(); i != vertices[n].e.end(); ++i)
      possible = possible && dfs(*i, 1 - color);
  }
  return possible;
}
int main() {
  int V, E;
  cin >> V >> E;
  for (int i = 0; i < E; i++) {
    int a, b;
    cin >> a >> b;
    edges[i] = a;
    vertices[a].e.push_back(b);
    vertices[b].e.push_back(a);
  }
  if (dfs(1, 1)) {
    cout << "YES" << endl;
    for (int i = 0; i < E; i++) cout << vertices[edges[i]].color;
    cout << endl;
  } else
    cout << "NO" << endl;
  return 0;
}
