#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
vector<int> vec[MAXN];
int color[MAXN];
int edge[MAXN];
int n, m, u, v, t;
int flag = 1;
void dfs(int x, int c) {
  color[x] = c;
  for (int i = 0, j = vec[x].size(); i < j; i++) {
    t = vec[x][i];
    if (!flag) return;
    if (color[t] == color[x]) {
      flag = 0;
      return;
    }
    if (color[t] == -1) dfs(t, !c);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    vec[u].push_back(v);
    vec[v].push_back(u);
    edge[i] = u;
  }
  memset(color, -1, sizeof(color));
  for (int i = 1; i <= n; i++) {
    if (!flag) break;
    if (color[i] == -1) {
      dfs(i, 0);
    }
  }
  if (!flag) {
    cout << "NO";
  } else {
    cout << "YES" << endl;
    for (int i = 0; i < m; i++) {
      cout << color[edge[i]];
    }
  }
  return 0;
}
