#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
const int INF = ~0U >> 2;
int n, m;
int vex[MAXN], g[MAXN], nextt[MAXN], tot;
void addin(int u, int v) {
  tot++;
  vex[tot] = v;
  nextt[tot] = g[u];
  g[u] = tot;
}
struct node {
  int idx, dis;
  node() {}
  node(int _idx, int _dis) {
    idx = _idx;
    dis = _dis;
  }
};
vector<node> longf[3010], longt[3010];
int vis[3010];
int boa[3010][3010];
queue<node> Q;
int cmp(node a, node b) {
  if (a.dis == b.dis) return a.idx < b.idx;
  return a.dis < b.dis;
}
void upf(node a, node b) {
  if (longf[a.idx].size() < 3)
    longf[a.idx].push_back(b);
  else
    longf[a.idx][0] = b;
  sort(longf[a.idx].begin(), longf[a.idx].end(), cmp);
}
void upt(node a, node b) {
  b.dis = a.dis;
  if (longt[a.idx].size() < 3)
    longt[a.idx].push_back(b);
  else
    longt[a.idx][0] = b;
  sort(longt[a.idx].begin(), longt[a.idx].end(), cmp);
}
void bfs(int s) {
  memset(vis, 0, sizeof vis);
  vis[s] = 1;
  node st(s, 0);
  Q.push(st);
  while (Q.size()) {
    node u = Q.front();
    Q.pop();
    for (int p = g[u.idx]; p; p = nextt[p]) {
      node v(vex[p], u.dis + 1);
      if (vis[vex[p]]) continue;
      vis[vex[p]] = 1;
      upf(st, v);
      upt(v, st);
      boa[st.idx][v.idx] = v.dis;
      Q.push(v);
    }
  }
}
int ans, anses[4];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int ui, vi;
    cin >> ui >> vi;
    addin(ui, vi);
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) boa[i][j] = INF;
  for (int i = 1; i <= n; i++) bfs(i);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int k = longt[i].size() - 1; k >= 0; k--)
        for (int l = longf[j].size() - 1; l >= 0; l--) {
          int a = longt[i][k].idx, b = i, c = j, d = longf[j][l].idx;
          if (boa[a][b] == INF || boa[b][c] == INF || boa[c][d] == INF)
            continue;
          if (a == b || a == c || d == b || d == c || a == d || b == c)
            continue;
          int sum = boa[a][b] + boa[b][c] + boa[c][d];
          if (sum > ans) {
            ans = sum;
            anses[0] = a;
            anses[1] = b;
            anses[2] = c;
            anses[3] = d;
          }
        }
  cout << anses[0] << " " << anses[1] << " " << anses[2] << " " << anses[3]
       << endl;
  return 0;
}
