#include <bits/stdc++.h>
using namespace std;
vector<int> graph[200005];
vector<pair<int, int>> edge;
int vis[200005], color[200005];
bool colorable;
void dfs(int u, int nodeClr) {
  vis[u] = 1;
  color[u] = nodeClr;
  for (int v : graph[u]) {
    if (vis[v] == 0) {
      dfs(v, nodeClr ^ 1);
    }
    if (color[v] == nodeClr) {
      colorable = false;
      return;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    graph[x].push_back(y);
    graph[y].push_back(x);
    edge.push_back(make_pair(x, y));
  }
  colorable = true;
  memset(color, -1, sizeof(color));
  dfs(1, 0);
  if (!colorable)
    cout << "NO" << '\n';
  else {
    cout << "YES" << '\n';
    for (int i = 0; i < m; ++i)
      cout << (color[edge[i].first] < color[edge[i].second]);
  }
  cout << '\n';
  return 0;
}
