#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int N = 1e6;
int n, m, k;
int ans = 0;
string s;
int b[1000006];
vector<int> G[200005];
bool vis[200005];
void dfs(int r, int d) {
  b[r] = d;
  vis[r] = true;
  for (int i = 0; i < G[r].size(); i++) {
    if (!vis[G[r][i]]) dfs(G[r][i], d ^ 1);
  }
  return;
}
pair<int, int> edge[200005];
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    edge[i].first = u;
    edge[i].second = v;
    G[v].push_back(u);
    G[u].push_back(v);
  }
  dfs(1, 0);
  for (int i = 0; i < m; i++) {
    int v, u;
    v = edge[i].first;
    u = edge[i].second;
    if (b[v] == b[u]) {
      cout << "NO" << '\n';
      return 0;
    } else if (b[v] == 0) {
      s += '1';
    } else
      s += '0';
  }
  cout << "YES" << '\n';
  cout << s << '\n';
  return 0;
}
