#include <bits/stdc++.h>
const int N = 3001;
using namespace std;
vector<int> G[N], rG[N], q[N];
int d[N][N];
bool vis[N];
int c[N][3], rc[N][3];
void bfs(int k, vector<int> g[], bool f) {
  int h = 0, t = 1, i, p;
  memset(vis, false, sizeof(vis));
  q[k].clear();
  q[k].push_back(k);
  if (f) d[k][k] = 0;
  vis[k] = true;
  h = 0;
  t = 1;
  while (h < t) {
    p = q[k][h++];
    for (i = 0; i < g[p].size(); i++)
      if (!vis[g[p][i]]) {
        if (f) d[k][g[p][i]] = d[k][p] + 1;
        q[k].push_back(g[p][i]);
        vis[g[p][i]] = true;
        t++;
      }
  }
}
int main() {
  int n, m;
  int i, j, k, l, a, b;
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    a--;
    b--;
    G[a].push_back(b);
    rG[b].push_back(a);
  }
  memset(d, -1, sizeof(d));
  for (i = 0; i < n; i++) bfs(i, G, true);
  memset(c, -1, sizeof(c));
  for (i = 0; i < n; i++) {
    for (j = q[i].size() - 1; j >= (int)q[i].size() - 3 && j > 0; j--) {
      c[i][q[i].size() - 1 - j] = q[i][j];
    }
  }
  for (i = 0; i < n; i++) bfs(i, rG, false);
  memset(rc, -1, sizeof(c));
  for (i = 0; i < n; i++)
    for (j = q[i].size() - 1; j >= (int)q[i].size() - 3 && j > 0; j--) {
      rc[i][q[i].size() - 1 - j] = q[i][j];
    }
  int s = 0, v1 = -1, v2 = -1, v3 = -1, v4 = -1;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      if (d[i][j] != -1 && i != j) {
        for (k = 0; k < 3 && rc[i][k] != -1; k++)
          for (l = 0; l < 3 && c[j][l] != -1; l++) {
            if (rc[i][k] != c[j][l] && rc[i][k] != j && c[j][l] != i) {
              if (d[rc[i][k]][i] + d[i][j] + d[j][c[j][l]] > s) {
                s = d[rc[i][k]][i] + d[i][j] + d[j][c[j][l]];
                v1 = rc[i][k];
                v2 = i;
                v3 = j;
                v4 = c[j][l];
              }
            }
          }
      }
  printf("%d %d %d %d\n", v1 + 1, v2 + 1, v3 + 1, v4 + 1);
  return 0;
}
