Why greedy fails in CHEFTRIP?

Here a case for which your output is wrong.

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

Also refer the editorial for the solution:

1 Like