class UnionFind
  attr :parent, :rank
  def initialize
    @parent = Hash.new
    @rank = Hash.new
  end
  def make(x)
    @parent[x] = x
    @rank[x] = 0
  end
  def union(a, b)
    x, y = find(a), find(b)
    x, y = y, x if @rank[x] < @rank[y]
    @parent[y] = x
    @rank[x] += 1 if @rank[x] == @rank[y]
  end
  def find(x)
    @parent[x] == x ? x : @parent[x] = find(@parent[x])
  end
  def size
    @parent.keys.map{|k| find(k)}.sort.uniq.size
  end
end

until (n, m = gets.split.map(&:to_i)).all?(&:zero?)
  degree = Array.new(n, 0)
  set = UnionFind.new
  n.times do |i| set.make(i) end
  m.times do
    u, v = gets.split.map{|i| i.to_i - 1}
    degree[u] += 1
    degree[v] += 1
    set.union(u, v)
  end
  puts (degree.all?{|i| i <= 2} && (degree.count{|i| i == 0} + degree.count{|i| i == 1} / 2) == set.size) ? "yes" : "no"
end