#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long mas[N];
long long used[N];
vector<long long> g[N];
long long col[N];
long long firstForEdge[N];
void dfs(long long a, long long cc = 1, long long p = -1) {
  col[a] = cc;
  for (auto c : g[a]) {
    if (!col[c]) {
      dfs(c, 3 - cc, a);
    } else if (col[c] == col[a]) {
      cout << "NO";
      exit(0);
    }
  }
}
void solve() {
  long long n, m;
  cin >> n >> m;
  for (long long i = (long long)0; i < (long long)m; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
    firstForEdge[i] = a;
  }
  dfs(0);
  cout << "YES\n";
  for (long long i = (long long)0; i < (long long)m; i++) {
    long long a = firstForEdge[i];
    cout << (col[a] == 1);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long tests = 1;
  while (tests--) {
    solve();
    cout << "\n";
  }
  return 0;
}
