#include <bits/stdc++.h>
using namespace std;
vector<int> vec[200010];
int a[200010], b[200010], color[200010];
bool flag = false;
void dfs(int now, int pre, int col) {
  color[now] = col;
  for (int i = 0; i < vec[now].size(); i++) {
    int v = vec[now][i];
    if (v == pre) continue;
    if (color[v] == -1)
      dfs(v, now, 1 - col);
    else if (color[v] == color[now])
      flag = true;
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  memset(color, -1, sizeof(color));
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    a[i] = u;
    b[i] = v;
    vec[u].push_back(v);
    vec[v].push_back(u);
  }
  dfs(1, -1, 0);
  if (flag) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  for (int i = 0; i < m; i++) {
    if (color[a[i]])
      cout << "0";
    else
      cout << "1";
  }
  cout << endl;
  return 0;
}
