#include <bits/stdc++.h>
using namespace std;
int visited[200005][2];
void dfs(int node, int count, int parent, vector<vector<int> > &adj) {
  visited[node][count % 2] = 1;
  for (auto k : adj[node]) {
    if (k == parent) {
      continue;
    }
    if (visited[k][(count + 1) % 2] == 1) {
      continue;
    }
    dfs(k, count + 1, node, adj);
  }
  return;
}
int main() {
  int no_of_input, no_of_edge;
  cin >> no_of_input >> no_of_edge;
  vector<pair<int, int> > edges;
  int input1, input2;
  vector<vector<int> > adj(no_of_input + 2);
  for (int i = 0; i < no_of_edge; i++) {
    cin >> input1 >> input2;
    edges.push_back({input1, input2});
    adj[input1].push_back(input2);
    adj[input2].push_back(input1);
  }
  for (int i = 0; i < 200005; i++) {
    for (int j = 0; j < 2; j++) {
      visited[i][j] = 0;
    }
  }
  dfs(1, 0, -1, adj);
  for (int i = 1; i <= no_of_input; i++) {
    if (visited[i][0] == 1 && visited[i][1] == 1) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES\n";
  for (int i = 0; i < edges.size(); i++) {
    cout << (visited[edges[i].first][0] > visited[edges[i].second][0]);
  }
}
