#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int N = 200001;
vector<int> adj[N];
bool vis[N];
int color[N];
bool flag = 0;
void dfs(int node, int c) {
  color[node] = c;
  for (auto it : adj[node]) {
    if (color[it] == -1) {
      dfs(it, c ^ 1);
    } else {
      if (color[it] == color[node]) flag = 1;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> pnts;
  int x, y;
  memset(vis, 0, sizeof vis);
  memset(color, -1, sizeof color);
  while (m--) {
    cin >> x >> y;
    x--;
    y--;
    pnts.push_back({x, y});
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(0, 0);
  if (flag)
    cout << "NO";
  else {
    cout << "YES\n";
    for (auto it : pnts) {
      cout << (color[it.first] < color[it.second]);
    }
  }
}
