

fun main(args:Array<String>):Unit {
    while (true) {
        val (n, m) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0 && m == 0) return
        val stone = Array(n) { UnionFindTree() }
        val edgeCount = Array(n){0}
        var canMake = true
        repeat(m) {
            val (u, v) = readLine()!!.trim().split(' ').map(String::toInt)
            canMake = canMake && !stone[u - 1].isSameUnion(stone[v - 1])
            stone[u - 1].merge(stone[v - 1])
            edgeCount[u - 1]++
            edgeCount[v - 1]++
        }
        println(if (canMake && edgeCount.none{it > 2}) "yes" else "no")
    }
}
class UnionFindTree{
    private var mParent:UnionFindTree? = null
    private fun parent():UnionFindTree {
        return when(mParent){
            null -> this
            else -> {
                mParent = mParent?.parent()
                mParent !!
            }
        }
    }
    fun isSameUnion(other:UnionFindTree):Boolean {
        return parent() == other.parent()
    }
    fun merge(other:UnionFindTree):Unit {
        if (!isSameUnion(other)){
            parent().mParent = other.parent()
        }
    }
}
