#include <bits/stdc++.h>
using namespace std;
const int MAX_size = 200005;
long long N, M;
long long i, j;
long long vis[MAX_size];
char color[MAX_size];
long long arr[MAX_size];
vector<long long> adj[MAX_size];
vector<long long> v1;
void initialize() {
  for (i = 0; i < MAX_size; i++) {
    vis[i] = 0;
    color[i] = 'w';
  }
}
queue<long long> q;
bool bipartite = true;
void bipartite_bfs(long long x) {
  q.push(x);
  vis[x] = 1;
  color[x] = 'b';
  while (!q.empty()) {
    long long topele = q.front();
    q.pop();
    for (i = 0; i < adj[topele].size(); i++) {
      if (color[topele] == color[adj[topele][i]]) {
        bipartite = false;
      }
      if (!vis[adj[topele][i]]) {
        if (color[topele] == 'b') {
          color[adj[topele][i]] = 'r';
        }
        if (color[topele] == 'r') {
          color[adj[topele][i]] = 'b';
        }
        q.push(adj[topele][i]);
        vis[adj[topele][i]] = 1;
      }
    }
  }
}
int main() {
  scanf("%lld%lld", &N, &M);
  for (i = 0; i < M; i++) {
    long long x, y;
    scanf("%lld%lld", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
    v1.push_back(x);
  }
  initialize();
  bipartite_bfs(1);
  if (bipartite == false) {
    cout << "NO";
    return 0;
  } else {
    cout << "YES\n";
    for (i = 0; i < v1.size(); i++) {
      if (color[v1[i]] == 'r') {
        cout << "1";
      }
      if (color[v1[i]] == 'b') {
        cout << "0";
      }
    }
  }
  return 0;
}
