#include <bits/stdc++.h>
const int MAX = (int)1e9;
const long long LMAX = (long long)1e15;
using namespace std;
void fasto() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
void custom() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "2", stdout);
}
void need() { fasto(); }
int n, m;
vector<int> g[200005], val(200005);
pair<int, int> p[200005];
vector<bool> v(200005);
bool dfs(int k, int l) {
  if (!v[k]) {
    v[k] = true;
    val[k] = l;
    for (int i : g[k]) {
      if (!dfs(i, 1 - l)) return false;
    }
  } else {
    if (val[k] != l) return false;
  }
  return true;
}
int main() {
  need();
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
    p[i] = {u, v};
  }
  if (!dfs(1, 0)) {
    cout << "NO";
    return 0;
  }
  cout << "YES" << '\n';
  for (int i = 0; i < m; i++) {
    int u = p[i].first;
    if (val[u] == 1)
      cout << 0;
    else
      cout << 1;
  }
  return 0;
}
