#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 9;
const long long inf = 2e5 + 1;
vector<long long> g[maxn];
long long n, m, x[maxn], y[maxn], color[maxn];
void adde(long long x, long long y) {
  g[x].push_back(y);
  g[y].push_back(x);
}
void DFS(long long cur, long long c) {
  long long i;
  color[cur] = c;
  for (i = 0; i < g[cur].size(); i++) {
    long long v = g[cur][i];
    if (color[v] == 0) DFS(v, -1 * c);
  }
}
bool enforce() {
  long long i;
  for (i = 1; i <= m; i++) {
    if (color[x[i]] == color[y[i]]) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    cin >> x[i] >> y[i];
    adde(x[i], y[i]);
  }
  DFS(1, 1);
  if (!enforce())
    cout << "NO";
  else {
    cout << "YES\n";
    for (long long i = 1; i <= m; i++) cout << max(0ll, color[x[i]]);
  }
}
