Ig my solution for GENTHRU problem in today's contest is incorrect

Problem: https://www.codechef.com/problems/GENTHRU?tab=statement

My submission: https://www.codechef.com/viewsolution/1399003959

During the contest, I assumed that if all nodes have at least 2 neighbours, then the answer should be 0 and developed a solution further based on that

My solution got AC during the contest. However, I found a counter example later during the contest:

1
6 7
1 2
2 3
3 1
4 5
5 6
6 4
1 4

The answer is supposed to be 1 (edge 1-4) but my solution outputs 0

Can someone help me understand whether my solution is incorrect or I misunderstood smth???

for _ in range(int(input())):

    n,m=map(int,input().split())

    neighs=[set() for _ in range(n+1)]

    for _ in range(m):

        u,v=map(int,input().split())

        neighs[u].add(v)

        neighs[v].add(u)

    curr=[]

    for i in range(1,n+1):

        if len(neighs[i])==1:curr.append(i)

    c=0

    while curr:

        c+=len(curr)

        nex=[]

        for u in curr:

            for v in neighs[u]:

                neighs[v].remove(u)

                if(len(neighs[v])==1):nex.append(v)

        curr=nex

    print(min(c,m))