#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const long long inf = 0x3f3f3f3fll;
const long long mod = 998244353ll;
int n, m;
vector<int> g[N];
bool vis[N], c[N];
int u[N], v[N];
int main() {
  ios::sync_with_stdio(0);
  int i, j;
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    cin >> u[i] >> v[i];
    g[u[i]].push_back(v[i]);
    g[v[i]].push_back(u[i]);
  }
  queue<int> q;
  c[1] = 1;
  vis[1] = 1;
  q.push(1);
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    for (auto v : g[cur]) {
      if (vis[v]) continue;
      vis[v] = 1;
      c[v] = !c[cur];
      q.push(v);
    }
  }
  for (i = 1; i <= m; i++) {
    if (c[u[i]] == c[v[i]]) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES" << endl;
  for (i = 1; i <= m; i++) cout << c[u[i]];
  return 0;
}
