#include <bits/stdc++.h>
using namespace std;
long long n, m;
vector<long long> adj[200005];
map<pair<long long, long long>, long long> pam;
long long c[200005];
bool visited[200005];
bool flg = true;
long long ans[200005];
void dfs(long long s, long long C) {
  visited[s] = true;
  c[s] = C;
  for (long long i = 0; i < adj[s].size(); i++) {
    long long v = adj[s][i];
    if (visited[v] == false) {
      dfs(v, 1 - C);
    } else {
      if (c[v] != (1 - C)) {
        flg = false;
      }
    }
  }
}
void dfs2(long long s) {
  visited[s] = true;
  for (long long i = 0; i < adj[s].size(); i++) {
    long long v = adj[s][i];
    if (visited[v] == false) {
      if (c[s] == 0) {
        if (pam[{s, v}] == 0) {
          ans[pam[{v, s}]] = 1;
        } else {
          ans[pam[{s, v}]] = 0;
        }
      } else {
        if (pam[{v, s}] == 0) {
          ans[pam[{s, v}]] = 1;
        } else {
          ans[pam[{v, s}]] = 0;
        }
      }
    }
  }
  for (long long i = 0; i < adj[s].size(); i++) {
    long long v = adj[s][i];
    if (visited[v] == false) {
      dfs2(v);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  long long M = m;
  long long a, b;
  for (long long i = 1; i <= m; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
    pam[{a, b}] = i;
  }
  memset(visited, false, sizeof(visited));
  dfs(1, 0);
  if (flg == false)
    cout << "NO";
  else {
    cout << "YES\n";
    memset(visited, false, sizeof(visited));
    dfs2(1);
    for (long long i = 1; i <= m; i++) cout << ans[i];
  }
}
