#include <bits/stdc++.h>
using namespace std;
vector<int> v[200005];
int color[200005], a[200005], b[2000005];
int flag, n, m;
void dfs(int x, int fa, int y) {
  color[x] = y;
  for (int i = 0; i < v[x].size(); i++) {
    int n = v[x][i];
    if (n == fa) continue;
    if (color[n] == -1)
      dfs(n, x, 1 - y);
    else if (color[n] == color[x])
      flag = 0;
  }
  return;
}
int main() {
  scanf("%d%d", &n, &m);
  memset(color, -1, sizeof(color));
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a[i], &b[i]);
    v[a[i]].push_back(b[i]);
    v[b[i]].push_back(a[i]);
  }
  flag = 1;
  dfs(1, -1, 0);
  if (!flag) {
    printf("NO\n");
    return 0;
  }
  printf("YES\n");
  for (int i = 0; i < m; i++) {
    if (color[a[i]] == 1)
      printf("1");
    else
      printf("0");
  }
  printf("\n");
  return 0;
}
