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

**URL:** <https://discuss.codechef.com/t/ig-my-solution-for-genthru-problem-in-todays-contest-is-incorrect/126193>\
**Category:** general\
**Created:** [November 23, 2026, 4:51pm UTC](https://discuss.codechef.com/t/ig-my-solution-for-genthru-problem-in-todays-contest-is-incorrect/126193 "2026-11-23T16:51:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jothinkumar](https://discuss.codechef.com/user_avatar/discuss.codechef.com/jothinkumar/32/361505_2.png) [@jothinkumar](https://discuss.codechef.com/u/jothinkumar)\
**Post date:** [November 23, 2026, 4:51pm UTC](https://discuss.codechef.com/t/ig-my-solution-for-genthru-problem-in-todays-contest-is-incorrect/126193/1 "2026-11-23T16:51:52Z")

</div>

Problem: [https://www.codechef.com/problems/GENTHRU?tab=statement](https://www.codechef.com/problems/GENTHRU?tab=statement)

My submission: [https://www.codechef.com/viewsolution/1399003959](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

 ![Screenshot 2026-11-23 at 22-13-51 Graph Editor](https://s3.amazonaws.com/discourseproduction/original/4X/2/f/d/2fd77cd12a50dd360393f233cc8afb4005543820.png)

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

```python
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))

```
