#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
const long long inf64 = 1e18;
const long long mod = inf + 7;
const long long N = 2e5 + 10;
long long n, m;
vector<long long> adj[N], clr(N, -1);
vector<pair<long long, long long> > edge;
bool ok = 1;
void dfs(long long s, long long col) {
  clr[s] = col;
  for (long long x : adj[s]) {
    if (clr[x] == -1)
      dfs(x, col ^ 1);
    else if (clr[x] == col)
      ok = false;
  }
}
void solve() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
    edge.push_back({x, y});
  }
  dfs(1, 0);
  if (!ok) {
    cout << "NO";
    return;
  }
  cout << "YES\n";
  for (long long i = 0; i < m; i++) {
    if (clr[edge[i].first] == 1)
      cout << 1;
    else
      cout << 0;
  }
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long tc = 1;
  while (tc--) solve();
}
