#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void umax(T &x, T y) {
  if (y > x) x = y;
}
template <class T>
inline void umin(T &x, T y) {
  if (y < x) x = y;
}
const int N = 4e3 + 5, B = 0x7fffffff;
vector<pair<int, int> > gel[N];
vector<pair<int, int> > git[N];
int way[N][N];
vector<int> g[N];
vector<int> res = {0, 0, 0, 0};
bool seen[N][N];
int ans;
int n, m;
void bfs(int node) {
  queue<int> Q;
  bool vis[N];
  int cost[N];
  memset(vis, 0, sizeof vis);
  memset(cost, 0, sizeof cost);
  Q.push(node);
  while (!Q.empty()) {
    int fr = Q.front();
    vis[fr] = 1;
    Q.pop();
    for (int adj : g[fr]) {
      if (vis[adj] == 0) {
        cost[adj] = cost[fr] + 1;
        way[node][adj] = cost[adj];
        git[node].push_back({cost[adj], adj});
        gel[adj].push_back({cost[adj], node});
        vis[adj] = 1;
        Q.push(adj);
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, u, v; i <= m; i++) {
    scanf("%d%d", &u, &v);
    if (u != v && seen[u][v] == 0) g[u].push_back(v);
    seen[u][v] = 1;
  }
  for (int i = 1; i <= n; i++) bfs(i);
  for (int i = 1; i <= n; i++) {
    sort((git[i]).begin(), (git[i]).end());
    sort((gel[i]).begin(), (gel[i]).end());
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      if (way[i][j] == 0) continue;
      if ((int)gel[i].size() < 1 || (int)git[j].size() < 1) continue;
      int k1 = -1, k2 = -1, k3 = -1, k4 = -1;
      bool ok = 1;
      for (int k = (int)gel[i].size() - 1; k >= 0; k--) {
        if (gel[i][k].second != i && gel[i][k].second != j) {
          k1 = k;
          break;
        }
        if (k == 0) ok = 0;
      }
      for (int k = (int)git[j].size() - 1; k >= 0; k--) {
        if (git[j][k].second != j && git[j][k].second != i &&
            git[j][k].second != gel[i][k1].second) {
          k2 = k;
          break;
        }
        if (k == 0) ok = 0;
      }
      if (way[i][j] + gel[i][k1].first + git[j][k2].first > ans && ok) {
        ans = way[i][j] + gel[i][k1].first + git[j][k2].first;
        res = {gel[i][k1].second, i, j, git[j][k2].second};
      }
      ok = 1;
      for (int k = (int)git[j].size() - 1; k >= 0; k--) {
        if (git[j][k].second != j && git[j][k].second != i) {
          k3 = k;
          break;
        }
        if (k == 0) ok = 0;
      }
      for (int k = (int)gel[i].size() - 1; k >= 0; k--) {
        if (gel[i][k].second != i && gel[i][k].second != j &&
            gel[i][k].second != git[j][k3].second) {
          k4 = k;
          break;
        }
        if (k == 0) ok = 0;
      }
      if (way[i][j] + gel[i][k4].first + git[j][k3].first > ans && ok) {
        ans = way[i][j] + gel[i][k4].first + git[j][k3].first;
        res = {gel[i][k4].second, i, j, git[j][k3].second};
      }
    }
  }
  for (int x : res) printf("%d ", x);
  return !!0;
}
