diff --git a/buggy.py b/buggy.py
--- a/buggy.py
+++ b/buggy.py
@@ -26,7 +26,7 @@
                         C[v][b] = cnt
                         q2.append((v, b))
     q, q2 = q2, q
-if min(C[N]) == N:
+if min(C[N]) == INF:
     print(-1)
 else:
     print(min(C[N]))
