#include <bits/stdc++.h>
using namespace std;
int ar[3005];
char ch[3005];
int n, m, ii, k;
int dist[3005][3005];
vector<int> g[3005];
void bfs(int u) {
  dist[u][u] = 0;
  queue<int> q;
  q.push(u);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (auto it : g[v]) {
      if (dist[u][it] > dist[u][v] + 1) {
        dist[u][it] = dist[u][v] + 1;
        q.push(it);
      }
    }
  }
}
void solve() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) dist[i][j] = 1000000007;
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
  }
  for (int i = 1; i <= n; i++) bfs(i);
  vector<pair<int, int>> dv[n + 5], rdv[n + 5];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j || dist[i][j] == 1000000007) continue;
      dv[i].push_back({dist[i][j], j});
      rdv[j].push_back({dist[i][j], i});
    }
    sort(dv[i].rbegin(), dv[i].rend());
  }
  for (int i = 1; i <= n; i++) sort(rdv[i].rbegin(), rdv[i].rend());
  int re = 0;
  int a, b, c, d;
  for (int i = 1; i <= n; i++) {
    int sz = dv[i].size();
    int a1 = i;
    for (int j = 0; j < sz; j++) {
      int b1 = dv[i][j].second;
      if (b1 == a1) continue;
      int sz1 = dv[b1].size();
      for (int l = 0; l < min(sz1, 4); l++) {
        int c1 = dv[b1][l].second;
        if (a1 == c1 || b1 == c1) continue;
        int sz2 = rdv[a1].size();
        for (int x = 0; x < min(sz2, 4); x++) {
          int d1 = rdv[a1][x].second;
          if (a1 == d1 || b1 == d1 || c1 == d1) continue;
          int tem = dist[a1][b1] + dist[b1][c1] + dist[d1][a1];
          if (re < tem) {
            re = tem;
            a = d1;
            b = a1;
            c = b1;
            d = c1;
          }
        }
      }
    }
  }
  printf("%d %d %d %d\n", a, b, c, d);
}
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
