#include <bits/stdc++.h>
const long double pie = 3.1415926535;
using namespace std;
long long fpow(long long n, long long p) {
  long long m = 1;
  while (p) {
    if (p % 2) m *= n;
    p >>= 1;
    n *= n;
  }
  return m;
}
long long mfpow(long long n, long long p, long long M) {
  long long m = 1;
  n %= M;
  while (p) {
    if (p % 2) m = (m * n) % M;
    n = (n * n) % M;
    p >>= 1;
  }
  return m % M;
}
const vector<long long> days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool br1, br2, br;
char ch, ch1, ch2;
long long n, k, x, y, z, mini, maxi, l, ind, ini, sum, t, len, r, w, imini, m;
string s, s1, s2;
vector<long long> v[(int)1e6 + 100];
vector<pair<long long, long long> > edg;
bool vis[(int)1e6 + 100];
bool col[(int)1e6 + 100];
void dfs(long long x, bool y) {
  if (vis[x]) {
    if (col[x] != y) br = 1;
    return;
  }
  vis[x] = 1;
  col[x] = y;
  for (auto i : v[x]) dfs(i, y ^ 1);
}
void solve() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    edg.push_back(make_pair(x, y));
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(0, 0);
  if (br)
    cout << "NO\n";
  else {
    cout << "YES\n";
    for (auto i : edg) s.push_back('0' + col[i.first]);
    cout << s << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  solve();
  return 0;
}
