#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > tree;
int color[200005];
int n, m;
bool flag = true;
void dfs(int ver, int par, int col) {
  if (color[ver] != -1 and color[ver] != col) flag = false;
  if (color[ver] != -1) return;
  color[ver] = col;
  for (int u : tree[ver]) {
    if (u == par) continue;
    dfs(u, ver, col ^ 1);
  }
}
int main() {
  memset(color, -1, sizeof(color));
  cin >> n >> m;
  tree.resize(n + 5);
  vector<pair<int, int> > edges;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    tree[x].push_back(y);
    tree[y].push_back(x);
    edges.push_back({x, y});
  }
  dfs(1, 1, 0);
  if (!flag) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  string ans = "";
  for (pair<int, int> vv : edges) {
    if (color[vv.first] == 0 and color[vv.second] == 1)
      ans += '1';
    else
      ans += '0';
  }
  cout << ans;
}
