#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> graph;
vector<int> color;
bool bipartite;
void dfs(int vertex) {
  int next_color = color[vertex] * -1;
  for (int item : graph[vertex]) {
    if (color[item] == color[vertex])
      bipartite = false;
    else if (color[item] == 0) {
      color[item] = next_color;
      dfs(item);
    }
  }
}
int main() {
  int n, m;
  while (cin >> n >> m) {
    bipartite = true;
    graph.resize(n + 1);
    color.resize(n + 1);
    vector<pair<int, int>> input(m);
    for (int i = 0; i < m; i++) {
      cin >> input[i].first >> input[i].second;
      graph[input[i].first].push_back(input[i].second);
      graph[input[i].second].push_back(input[i].first);
    }
    color[1] = -1;
    dfs(1);
    if (!bipartite) {
      cout << "NO" << endl;
    } else {
      cout << "YES" << endl;
      for (int i = 0; i < input.size(); i++) {
        if (color[input[i].first] < color[input[i].second]) {
          cout << "0";
        } else {
          cout << "1";
        }
      }
      cout << endl;
    }
  }
  return 0;
}
