#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
pair<int, int> pp;
vector<int> e[2 * maxn];
map<pair<int, int>, int> mp;
int d[2 * maxn];
int vis[2 * maxn];
int ans[2 * maxn];
int flag = 1;
void dfs(int now, int fx) {
  if (flag == 0) return;
  int sz = e[now].size();
  for (int i = 0; i < sz; i++) {
    int to = e[now][i];
    if (vis[to] == 1) {
      if (d[to] == (d[now] + 1) % 2)
        ;
      else
        flag = 0;
      pp.first = now;
      pp.second = to;
      if (mp[pp] > 0) {
        int f = mp[pp];
        if (fx == 1)
          ans[f] = 0;
        else
          ans[f] = 1;
      } else {
        pp.first = to;
        pp.second = now;
        int f = mp[pp];
        if (fx == 1)
          ans[f] = 1;
        else
          ans[f] = 0;
      }
      continue;
    }
    d[to] = (d[now] + 1) % 2;
    vis[to] = 1;
    pp.first = now;
    pp.second = to;
    if (mp[pp] > 0) {
      int f = mp[pp];
      if (fx == 1)
        ans[f] = 0;
      else
        ans[f] = 1;
    } else {
      pp.first = to;
      pp.second = now;
      int f = mp[pp];
      if (fx == 1)
        ans[f] = 1;
      else
        ans[f] = 0;
    }
    dfs(to, (fx + 1) % 2);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  int cnt = 1;
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    pp.first = x;
    pp.second = y;
    mp[pp] = cnt;
    cnt++;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  vis[1] = 1;
  d[1] = 0;
  dfs(1, 1);
  if (flag == 0)
    printf("NO\n");
  else {
    printf("YES\n");
    for (int i = 0; i < m; i++) {
      printf("%d", ans[i + 1]);
    }
  }
}
