#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long poww(long long x, long long y, long long p) {
  long long ans = 1;
  while (y) {
    if (y & 1) ans = ans * x % p;
    x = x * x % p;
    y >>= 1;
  }
  return ans % p;
}
bool isp(long long x) {
  if (x < 2) return 0;
  for (long long i = 2; i * i <= x; i++) {
    if (x % i == 0) return 0;
  }
  return 1;
}
int n, k, u, v;
pair<int, int> e[maxn];
vector<int> g[maxn];
map<pair<int, int>, int> m;
bool vis[maxn];
bool ok = 1;
void dfs(int u, int fa, int d) {
  if (vis[u]) return;
  vis[u] = 1;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v == fa) continue;
    m[make_pair(u, v)] = d;
    if (m.count(make_pair(v, u)) && m[make_pair(v, u)] != -d) ok = 0;
    dfs(v, u, -d);
  }
  return;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
    e[i] = make_pair(u, v);
  }
  dfs(1, -1, 1);
  if (!ok) {
    puts("NO");
    return 0;
  }
  puts("YES");
  pair<int, int> tmp = make_pair(0, 0);
  for (int i = 0; i < k; i++) {
    if (m.count(e[i])) {
      if (m[e[i]] == 1)
        printf("0");
      else
        printf("1");
    } else {
      tmp = make_pair(e[i].second, e[i].first);
      if (m[tmp] == 1)
        printf("1");
      else
        printf("0");
    }
  }
  puts("");
  return 0;
}
