#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, id, num;
};
vector<edge> G[201000];
int color[201000];
int ans[200100];
bool dfs(int x) {
  for (int i = 0; i < G[x].size(); i++) {
    int to = G[x][i].to;
    if (!color[to]) {
      color[to] = 3 - color[x];
      if (dfs(to)) return 1;
    }
    if (color[to] + color[x] != 3) {
      return 1;
    }
  }
  return 0;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(edge{b, 1, i});
    G[b].push_back(edge{a, 2, i});
  }
  color[1] = 1;
  if (dfs(1)) {
    cout << "NO";
    return 0;
  }
  cout << "YES" << endl;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < G[i].size(); j++) {
      if (G[i][j].id == 2) continue;
      if (color[i] == 1)
        ans[G[i][j].num] = 1;
      else
        ans[G[i][j].num] = 0;
    }
  }
  for (int i = 1; i <= m; i++) cout << ans[i];
  return 0;
}
