CSES - Aalto Competitive Programming 2024 - wk7 - Mon - Road blockade
  • Time limit: 1.00 s
  • Memory limit: 512 MB

A bank's been robbed! Fortunately the robbers have chosen their target exceptionally poorly: the bank resides on an island that has only one bridge out. The police is going to just set blockade on the bridge and wait for the thieves to come to them.

However, as a young and aspiring police officer Maija is having none of it. The robbers couldn't possibly be that stupid! She decides to take the matter to her own hands and rushes to put a blockade on the earliest road that the robbers have to cross in order to exit the island.

There are nn junctions numbered 1,2,,n1,2,\dots,n and mm bidirectional roads connecting them numbered 1,2,,m1,2,\dots,m. The ii-th road connects junctions aia_i and bib_i. The bank resides at junction 11 and the bridge at junction nn. There is guaranteed to be a path between every pair of junctions.

Input

The first line contains two integers nn and mm. The ii-th of next mm lines contains two integers aia_i and bib_i.

Output

Print the index of the road that Maija should blockade or 0 if the bridge is the only road guaranteed to be on the robbers' path.

Constraints

  • 2n1052 \leq n \leq 10^5
  • 1m2×1051 \leq m \leq 2 \times 10^5
  • 1ai,bin1 \leq a_i, b_i \leq n
  • (ai,bi)(aj,bj)(a_i, b_i) \neq (a_j, b_j) if iji \neq j

Example 1

Input:

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

Output:

3

Example 2

Input:

4 4
1 2
1 3
2 4
3 4

Output:

0

Example 2

Input:

3 2
2 3
1 2

Output:

2