#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using iii = tuple<int, int, int>;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<int> t(n);
  vector<pii> e(m);
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    cin >> e[i].first >> e[i].second;
    --e[i].first, --e[i].second;
    g[e[i].first].push_back(e[i].second);
    g[e[i].second].push_back(e[i].first);
  }
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int i = q.front();
    q.pop();
    for (int j : g[i]) {
      if (t[j] == 0)
        t[j] = t[i] == 1 ? 2 : 1, q.push(j);
      else if (t[i] == t[j]) {
        cout << "NO";
        exit(0);
      };
    }
  }
  cout << "YES" << '\n';
  for (int i = 0; i < m; i++) cout << (t[e[i].first] - 1);
}
