#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6;
int n, m, x, y;
vector<int> Map[MAX], vis(MAX, -1);
vector<pair<int, int> > ans;
bool OK = true;
void DFS(int v, int u) {
  vis[v] = u;
  for (auto it : Map[v]) {
    if (vis[it] == -1)
      DFS(it, u ^ 1);
    else if (vis[it] == vis[v])
      OK = false;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    --x;
    --y;
    Map[x].push_back(y);
    Map[y].push_back(x);
    ans.push_back({x, y});
  }
  DFS(0, 0);
  if (!OK) {
    cout << "NO";
    return 0;
  }
  cout << "YES" << endl;
  for (int i = 0; i < m; i++) {
    int fs = ans[i].first;
    int sc = ans[i].second;
    cout << (vis[fs] < vis[sc]);
  }
  return 0;
}
