#include <bits/stdc++.h>
using namespace std;
const long double E = 2.71828182845904523536;
const long double pi = acos(-1);
const double eps = 1e-9;
const long long mod = 1e9 + 7;
const long long inf = 1LL << 30;
const int N = 200200;
vector<int> adj[N];
vector<int> adj2[N];
map<pair<int, int>, int> mp;
bool vis[N];
bool col[N];
pair<int, int> a[N];
bool ok = 1;
void DFS(int u, bool c) {
  vis[u] = 1;
  col[u] = c;
  for (auto v : adj[u]) {
    if (vis[v]) continue;
    DFS(v, !c);
  }
}
void DFS2(int u, int cnt) {
  if (cnt > 1) {
    ok = 0;
    return;
  }
  for (auto v : adj2[u]) DFS2(v, cnt + 1);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
    a[i] = {u, v};
  }
  DFS(1, 1);
  for (int u = 1; u <= n; u++) {
    if (col[u]) {
      for (auto v : adj[u]) {
        mp[{u, v}] = 1;
        mp[{v, u}] = 0;
        adj2[u].push_back(v);
      }
    } else {
      for (auto v : adj[u]) {
        mp[{u, v}] = 0;
        mp[{v, u}] = 1;
        adj2[v].push_back(u);
      }
    }
  }
  for (int u = 1; u <= n; u++) DFS2(u, 0);
  if (!ok) {
    printf("NO");
    return 0;
  }
  printf("YES\n");
  for (int i = 0; i < m; i++) printf("%d", mp[{a[i].first, a[i].second}]);
  return 0;
}
