#include <bits/stdc++.h>
using namespace std;
long long dx[] = {-1, 0, 1, 0};
long long dy[] = {0, 1, 0, -1};
long long spf[1];
void sieve() {
  long long i, j;
  for (i = 0; i < 1; i++) spf[i] = i;
  for (i = 4; i < 1; i += 2) spf[i] = 2;
  for (i = 3; i * i < 1; i++) {
    if (spf[i] == i) {
      for (j = i * i; j < 1; j += i) {
        if (spf[j] == j) spf[j] = i;
      }
    }
  }
}
bool isvowel(char c) {
  switch (c) {
    case 'a':
    case 'e':
    case 'i':
    case 'o':
    case 'u':
    case 'y':
      return true;
    default:
      return false;
  }
}
bool isPrime(long long n) {
  for (long long i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
long long sum(long long n) {
  long long ans = 0;
  while (n > 0) {
    long long d = n % 10;
    ans += d;
    n /= 10;
  }
  return ans;
}
vector<long long> adj[200005];
long long col[200005];
pair<long long, long long> e[200005];
long long bfs(long long node) {
  col[node] = 1;
  queue<long long> q;
  q.push(node);
  while (!q.empty()) {
    long long curr = q.front();
    q.pop();
    for (auto child : adj[curr]) {
      if (col[child] == -1) {
        col[child] = 1 - col[curr];
        q.push(child);
      } else if (col[child] == col[curr]) {
        return false;
      }
    }
  }
  return true;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    for (long long i = 1; i <= m; i++) {
      long long u, v;
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
      e[i] = {u, v};
    }
    memset(col, -1, sizeof(col));
    for (long long i = 1; i <= n; i++) {
      if (col[i] == -1) {
        if (bfs(i) == false) {
          cout << "NO"
               << "\n";
          return 0;
        }
      }
    }
    cout << "YES"
         << "\n";
    vector<long long> v;
    for (long long i = 1; i <= n; i++) {
      if (col[i] == 1) {
        v.push_back(i);
      }
    }
    for (long long i = 1; i <= m; i++) {
      if (col[e[i].first] == 0) {
        cout << "0";
      } else {
        cout << "1";
      }
    }
  }
  return 0;
}
