#include <bits/stdc++.h>
using namespace std;
long long n, m;
vector<long long> v[200005];
long long ans[200005];
bool ab = true;
void dfs(long long a, long long par) {
  ans[a] = par;
  for (int i = 0; i < v[a].size(); i++) {
    if (ans[v[a][i]] != -1) {
      if (ans[a] == ans[v[a][i]]) {
        ab = false;
      }
    } else {
      dfs(v[a][i], par ^ 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  while (t--) {
    cin >> n >> m;
    memset(ans, -1, sizeof(ans));
    pair<long long, long long> arr[m];
    for (int i = 0; i < m; i++) {
      long long a, b;
      cin >> a >> b;
      v[a].push_back(b);
      v[b].push_back(a);
      pair<long long, long long> p;
      p.first = a;
      p.second = b;
      arr[i] = p;
    }
    dfs(1, 0);
    if (ab) {
      cout << "YES"
           << "\n";
      for (int i = 0; i < m; i++) {
        if (ans[arr[i].first] < ans[arr[i].second]) {
          cout << 1;
        } else {
          cout << 0;
        }
      }
    } else {
      cout << "NO"
           << "\n";
    }
  }
  return 0;
}
