#include <bits/stdc++.h>
enum Group {
  NO,
  WHITE,
  BLACK,
};
void dfs(std::map<int32_t, std::list<int32_t>>& edges,
         std::vector<Group>& vertices, int32_t src, bool& interrupt) {
  for (auto dst : edges[src]) {
    if (vertices[dst] == Group::NO && vertices[src] == Group::WHITE) {
      vertices[dst] = Group::BLACK;
      dfs(edges, vertices, dst, interrupt);
    }
    if (vertices[dst] == Group::NO && vertices[src] == Group::BLACK) {
      vertices[dst] = Group::WHITE;
      dfs(edges, vertices, dst, interrupt);
    }
    if (vertices[dst] == vertices[src]) {
      interrupt = true;
      return;
    }
  }
}
int main() {
  int32_t n, m;
  std::list<std::pair<int32_t, int32_t>> input_edges;
  std::map<int32_t, std::list<int32_t>> edges;
  std::cin >> n >> m;
  for (int32_t i = 0; i < m; i++) {
    int32_t src, dst;
    std::cin >> src >> dst;
    src = src - 1;
    dst = dst - 1;
    input_edges.push_back(std::make_pair(src, dst));
    if (edges.find(src) == edges.end()) {
      edges[src] = std::list<int32_t>{dst};
    } else {
      edges[src].push_back(dst);
    }
    if (edges.find(dst) == edges.end()) {
      edges[dst] = std::list<int32_t>{src};
    } else {
      edges[dst].push_back(src);
    }
  }
  std::vector<Group> vertices(n);
  bool interrupt = false;
  vertices[0] = Group::WHITE;
  dfs(edges, vertices, 0, interrupt);
  if (interrupt) {
    std::cout << "NO" << std::endl;
    return 0;
  }
  std::cout << "YES" << std::endl;
  for (auto& edge : input_edges) {
    if (vertices[edge.first] == Group::WHITE &&
        vertices[edge.second] == Group::BLACK) {
      std::cout << '1';
    }
    if (vertices[edge.first] == Group::BLACK &&
        vertices[edge.second] == Group::WHITE) {
      std::cout << '0';
    }
  }
  std::cout << std::endl;
  return 0;
}
