#include <bits/stdc++.h>
using namespace std;
vector<int> adjList[200005];
bool komuNa = true, visited[200005];
int col[200005];
void dfs(int node, int cl) {
  visited[node] = true;
  col[node] = cl;
  for (int child : adjList[node]) {
    if (!visited[child]) {
      dfs(child, cl ^ 1);
    } else {
      if (col[node] == col[child]) {
        komuNa = false;
      }
    }
  }
}
int main() {
  int node, edge;
  scanf("%d", &node);
  ;
  scanf("%d", &edge);
  ;
  vector<pair<int, int> > kajeLagbe;
  for (int i = 1; i <= edge; i++) {
    int x, y;
    scanf("%d", &x);
    ;
    scanf("%d", &y);
    ;
    kajeLagbe.push_back({x, y});
    adjList[x].push_back(y);
    adjList[y].push_back(x);
  }
  dfs(1, 1);
  if (!komuNa)
    cout << "NO" << endl;
  else {
    cout << "YES" << endl;
    for (int i = 0; i < kajeLagbe.size(); i++) {
      if (col[kajeLagbe[i].first] == 1)
        cout << 1;
      else
        cout << 0;
    }
    cout << endl;
  }
}
