#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
using namespace std;
const int N = 1e3 + 5;
int n, m;
vector<int> g[N];
int d[N];
long long f(int u) {
queue<int> q;
memset(d, 0x3f, sizeof(d));
q.push(u);
d[u] = 0;
while (!q.empty()) {
int v = q.front();
q.pop();
for (int x : g[v]) {
if (d[x] > d[v] + 1) {
d[x] = d[v] + 1;
q.push(x);
}
}
}
return accumulate(d + 1, d + n + 1, 0LL);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= m; i++) {
int a, b;
cin >> a >> b;
g[a].emplace_back(b);
g[b].emplace_back(a);
}
long long ans = 1e18;
int res = -1;
for (int i = 1; i <= n; i++) {
long long v = f(i);
if (v < ans) {
ans = v;
res = i;
}
}
cout << res << '\n';
return 0;
}