CSES - Aalto Competitive Programming 2024 - wk7 - Wed - Town center
  • Time limit: 1.00 s
  • Memory limit: 512 MB

Uolevi continues his quest to find his long lost uncle. This time he has a strong lead: uncle has been sighted near the town center of Syrjälä. However, as Uolevi arrives to Syrjälä he quickly realizes that the place is so sparsely populated that figuring out where the 'center' isn't an easy task.

Uolevi buys a map of Syrjälä: it has n junctions numbered 1,2,\dots,n and m bidirectional roads connecting them. Road i connects junctions a_i and b_i and they are all the same length. There exists a path between every pair of junctions. He figures that the junction that minimizes the average distance to the other junctions is a good place to start searching.

Input

The first line contains two integers n and m. The i-th of next m lines contains two integers a_i and b_i.

Output

Print the number of the junction that minimizes the average distance. Formally, find a junction i such that i minimizes 1/n \times \sum_{j=1}^{n}{d(i,j)}, where d(i, j) is the number of roads on the shortest path between junctions i and j. If there are multiple answers then print the one with the smallest number.

Constraints

  • 2 \leq n \leq 1000
  • 1 \leq m \leq 5000
  • 1 \leq a_i < b_i \leq n
  • (a_i, b_i) \neq (a_j, b_j) if i \neq j

Example 1

Input:

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

Output:

2

Example 2

Input:

10 11
1 2
1 3
1 6
2 7
3 9
4 5
4 10
5 7
5 9
6 8
8 9

Output:

5