#include <bits/stdc++.h>
using namespace std;
long long MOD = pow(10, 9) + 7;
long long INF = 1e18 + 10;
const int N = 200005;
vector<int> adj[N];
bool vis[N];
map<pair<int, int>, int> m;
int fil[N];
int bfs(int a) {
  if (!vis[a]) {
    vis[a] = true;
    queue<int> q;
    q.push(a);
    fil[a] = 0;
    while (!q.empty()) {
      int b = q.front();
      q.pop();
      for (auto to : adj[b]) {
        if (to < 0) {
          if (fil[-to] == fil[b]) return 1;
          fil[-to] = 1 - fil[b];
          m[make_pair(-to, b)] = 1 - fil[b];
        } else if (to > 0) {
          if (fil[to] == fil[b]) return 1;
          fil[to] = 1 - fil[b];
          m[make_pair(b, to)] = fil[b];
        }
        if (to < 0 && !vis[-to])
          q.push(-to), vis[-to] = true;
        else if (to > 0 && !vis[to])
          q.push(to), vis[to] = true;
      }
    }
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> v;
  for (int i = 0; i < k; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(-a);
    v.push_back(make_pair(a, b));
  }
  memset(fil, -1, sizeof fil);
  int cant = bfs(1);
  if (cant)
    cout << "NO\n";
  else {
    cout << "YES\n";
    for (int i = 0; i < k; i++) cout << m[v[i]];
  }
}
