#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const long long maxn = 200005;
long long n, m, x, y, visited[maxn], c[maxn];
vector<pair<long long, long long> > temp;
set<long long> adj[maxn];
void dfs(long long u, long long cl) {
  visited[u] = 1;
  c[u] = cl;
  for (auto i = adj[u].begin(); i != adj[u].end(); i++) {
    if (!visited[*i] && c[u] != c[*i]) {
      dfs(*i, !cl);
    } else if (c[*i] == c[u]) {
      cout << "NO\n";
      exit(0);
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  memset(c, -1, sizeof c);
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    adj[x].insert(y);
    adj[y].insert(x);
    temp.push_back({x, y});
  }
  dfs(0, 0);
  cout << "YES\n";
  for (long long i = 0; i < m; i++) {
    cout << ((c[temp[i].first] < c[temp[i].second]) ? 1 : 0);
  }
  cout << "\n";
  return 0;
}
