#include <bits/stdc++.h>
using namespace std;
const long long int N = 2e5 + 5;
long long int n, m;
vector<long long int> gr[N];
long long int a[N], b[N];
long long int vis[N];
void dfs(long long int curr, long long int col) {
  vis[curr] = col;
  for (auto x : gr[curr]) {
    if (vis[x] == 0) {
      dfs(x, 3 - col);
    } else if (vis[x] == col) {
      cout << "NO";
      exit(0);
    }
  }
}
void solve() {
  cin >> n >> m;
  for (long long int i = 0; i < m; i++) {
    long long int u, v;
    cin >> u >> v;
    gr[u].push_back(v);
    gr[v].push_back(u);
    a[i] = u, b[i] = v;
  }
  memset(vis, 0, sizeof(vis));
  dfs(1, 1);
  cout << "YES" << '\n';
  for (long long int i = 0; i < m; i++) {
    if (vis[a[i]] < vis[b[i]]) {
      cout << 1;
    } else {
      cout << 0;
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
