#include <bits/stdc++.h>
using namespace std;
vector<long long int> g[300005];
long long int n, m, flag = 1;
map<pair<long long int, long long int>, long long int> ans;
long long int visit[300005];
long long int color[300005];
void dfs1(long long int src, long long int col) {
  visit[src] = 1;
  color[src] = col;
  for (long long int i = 0; i < g[src].size(); i++) {
    if (visit[g[src][i]] == 0) {
      long long int x;
      if (col == 0)
        x = 1;
      else
        x = 0;
      dfs1(g[src][i], x);
    }
  }
}
void dfs2(long long int src) {
  visit[src] = 1;
  for (long long int i = 0; i < g[src].size(); i++) {
    if (color[g[src][i]] == color[src]) {
      flag = 0;
      break;
    }
    if (color[src] == 0) {
      ans[{src, g[src][i]}] = 1;
    } else {
      ans[{src, g[src][i]}] = 0;
    }
    if (visit[g[src][i]] == 0) {
      dfs2(g[src][i]);
    }
  }
}
int32_t main() {
  cin >> n >> m;
  pair<long long int, long long int> arr[m];
  for (long long int i = 0; i < m; i++) {
    long long int a, b;
    cin >> a >> b;
    a--;
    b--;
    arr[i].first = a;
    arr[i].second = b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs1(0, 0);
  for (long long int i = 0; i < n; i++) visit[i] = false;
  dfs2(0);
  if (flag == 0)
    cout << "NO" << endl;
  else {
    cout << "YES" << endl;
    for (long long int i = 0; i < m; i++) {
      cout << ans[{arr[i].first, arr[i].second}];
    }
    cout << endl;
  }
}
