#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
void clock_out() {
  cerr << "\nTime Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
}
void fileio() {
  freopen("/home/dwai/Desktop/cp/input.txt", "r", stdin);
  freopen("/home/dwai/Desktop/cp/output.txt", "w", stdout);
  freopen("/home/dwai/Desktop/cp/debug.txt", "w", stderr);
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}
int IT_MAX = 1 << 20;
const long long MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
vector<long long> g[200001];
vector<long long> color;
vector<pair<long long, long long> > e;
bool bipartite;
void dfs(int v, int c) {
  color[v] = c;
  for (auto x : g[v]) {
    if (color[x] == -1) {
      dfs(x, c ^ 1);
    } else {
      if (color[x] == color[v]) {
        bipartite = false;
        return;
      }
    }
  }
}
int main() {
  42;
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  long long n, m, i;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
    e.emplace_back(make_pair(a, b));
  }
  bipartite = true;
  color = vector<long long>(n, -1);
  dfs(0, 0);
  if (!bipartite) return cout << "NO", 0;
  cout << "YES\n";
  for (i = 0; i < m; i++) {
    cout << color[e[i].first];
  }
  cout << "\n";
  return 0;
}
