#include <bits/stdc++.h>
using namespace std;
int const N = 2e5 + 10;
pair<int, int> edge[N];
vector<int> adj[N];
int n, m, nm = 1, h[N], num[N], color[N];
bool mark[N];
queue<int> q;
void read_input() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    edge[i] = make_pair(a, b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
}
bool is_bipartite(int s) {
  memset(color, -1, sizeof color);
  color[s] = 1;
  q.push(s);
  while (!q.empty()) {
    int v = q.front();
    for (auto u : adj[v]) {
      if (color[u] == -1) {
        color[u] = !color[v];
        h[u] = h[v] + 1;
        q.push(u);
      } else if (color[u] == color[v])
        return false;
    }
    q.pop();
  }
  return true;
}
void solve() {
  if (!is_bipartite(0)) {
    cout << "NO";
    return;
  }
  cout << "YES" << '\n';
  for (int i = 0; i < m; i++) cout << !(h[edge[i].first] % 2);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  read_input();
  solve();
}
