#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 100;
int n, m;
vector<int> Graph[maxn];
vector<pair<int, int> > e;
bool is_Bipartite;
vector<int> color;
void dfs(int v, int c) {
  color[v] = c;
  for (auto it : Graph[v]) {
    if (color[it] == -1) {
      dfs(it, c ^ 1);
    } else {
      if (color[it] == color[v]) is_Bipartite = false;
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    Graph[x].push_back(y);
    Graph[y].push_back(x);
    e.push_back({x, y});
  }
  is_Bipartite = true;
  color.assign(n, -1);
  dfs(0, 0);
  if (!is_Bipartite) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  for (int i = 0; i < m; i++) {
    cout << (color[e[i].first] < color[e[i].second]);
  }
  cout << "\n";
  return 0;
}
