#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
vector<vector<int>> gr;
vector<int> col;
int change(int cur) {
  if (cur == 1) return 2;
  return 1;
}
void dfs(int v, int cur) {
  cur = change(cur);
  col[v] = cur;
  for (auto u : gr[v]) {
    if (col[u] && col[u] == cur) cout << "NO", exit(0);
    if (!col[u]) dfs(u, cur);
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n, m;
  cin >> n >> m;
  gr.resize(n);
  vector<pair<int, int>> edges(m);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    gr[a].push_back(b), gr[b].push_back(a);
    edges[i] = {a, b};
  }
  col.resize(n);
  for (int i = 0; i < n; i++)
    if (!col[i]) dfs(i, 1);
  cout << "YES\n";
  for (auto i : edges) cout << col[i.first] - 1;
  return 0;
}
