#include <bits/stdc++.h>
using namespace std;
void Open() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int dx[]{1, -1, 0, 0, 1, 1, -1, -1};
int dy[]{0, 0, 1, -1, 1, -1, 1, -1};
const int OO = 0x3f3f3f3f;
int n, m, s;
int vis[200002];
int c[200002];
vector<vector<int>> g;
void dfs(int node, int pr) {
  vis[node] = 1;
  c[node] = pr;
  for (auto it : g[node]) {
    if (!vis[it]) {
      dfs(it, 3 - pr);
    }
  }
}
void test_case() {
  cin >> n >> m;
  int w = -1;
  g = vector<vector<int>>(n + 1);
  vector<pair<int, int>> a(m);
  int x, y;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    a[i] = make_pair(x, y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1, 1);
  string ans;
  for (int i = 0; i < m; i++) {
    if (c[a[i].first] == c[a[i].second]) {
      cout << "NO";
      return;
    }
    ans += '0' + !(c[a[i].first] - 1);
  }
  cout << "YES"
       << "\n"
       << ans;
}
int main() {
  Open();
  int t = 1;
  while (t--) {
    test_case();
  }
}
