#include <bits/stdc++.h>
using namespace std;
vector<long long> v[200005], vis(200005), side(200005);
long long flag = 0;
void bfs(int x) {
  int i, b;
  vis[x] = 1;
  queue<long long> q;
  q.push(x);
  while (!q.empty()) {
    b = q.front();
    q.pop();
    for (i = 0; i < v[b].size(); i++) {
      if (side[v[b][i]] == 0) {
        if (side[b] == 1)
          side[v[b][i]] = 2;
        else
          side[v[b][i]] = 1;
        vis[v[b][i]] = 1;
        q.push(v[b][i]);
      } else {
        if (side[b] == side[v[b][i]]) flag = 1;
      }
    }
  }
}
int main() {
  long long n, m, a, b, i;
  vector<long long> edge;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
    edge.push_back(a);
  }
  side[1] = 1;
  bfs(1);
  if (flag)
    cout << "NO";
  else {
    cout << "YES" << endl;
    for (i = 0; i < edge.size(); i++) cout << side[edge[i]] - 1;
  }
}
