#include <bits/stdc++.h>
using namespace std;
long long n = 2 * 1e5 + 1, flag = 0, root = 0;
vector<vector<long long>> adj(n);
vector<bool> visited(n);
vector<long long> v(n);
void dfs(long long s, long long anc, long long cnt) {
  if (visited[s]) return;
  visited[s] = true;
  if (v[anc] == 0)
    v[s] = 1;
  else
    v[s] = 0;
  cnt++;
  for (auto u : adj[s]) {
    dfs(u, s, cnt);
  }
}
int main() {
  long long m, e;
  cin >> m >> e;
  vector<pair<long long, long long>> ab(e);
  for (long long i = 0; i < e; i++) {
    cin >> ab[i].first >> ab[i].second;
    adj[ab[i].first].push_back(ab[i].second);
    adj[ab[i].second].push_back(ab[i].first);
    if (root == 0) root = ab[i].first;
  }
  dfs(root, 0, 0);
  for (long long i = 0; i < e; i++) {
    if (v[ab[i].first] == 0 && v[ab[i].second] == 0) {
      flag = 1;
      break;
    } else if (v[ab[i].first] == 1 && v[ab[i].second] == 1) {
      flag = 1;
      break;
    }
  }
  if (flag == 1) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  for (long long i = 0; i < e; i++) {
    if (v[ab[i].first] == 0)
      cout << 1;
    else
      cout << 0;
  }
  cout << endl;
  return 0;
}
