#include <bits/stdc++.h>
using namespace std;
int n, m;
struct node {
  int to, next, w;
} edge[22000];
struct node2 {
  int to, ds;
  node2() {}
  node2(int tto, int dds) : to(tto), ds(dds) {}
};
bool cmp(node2 x1, node2 y1) { return x1.ds > y1.ds; }
int cnt, pre[3300];
vector<node2> ve[3300], ev[3300];
int dis[3300][3300];
const int inf = 0x3f3f3f3f;
int vis[3300];
void init() {
  cnt = 0;
  memset(pre, -1, sizeof(pre));
  memset(dis, inf, sizeof(dis));
  for (int i = 0; i < 3300; i++) {
    ve[i].clear();
    ev[i].clear();
  }
}
void add_edge(int u, int v, int w) {
  edge[cnt].w = w;
  edge[cnt].to = v;
  edge[cnt].next = pre[u];
  pre[u] = cnt++;
}
void spfa(int st) {
  memset(vis, 0, sizeof(vis));
  queue<int> q;
  vis[st] = 1;
  q.push(st);
  dis[st][st] = 0;
  while (!q.empty()) {
    int z = q.front();
    for (int i = pre[z]; i != -1; i = edge[i].next) {
      int vv = edge[i].to;
      int ww = edge[i].w;
      if (dis[st][z] + ww < dis[st][vv]) {
        dis[st][vv] = dis[st][z] + ww;
        if (!vis[vv]) {
          q.push(vv);
          vis[vv] = 1;
        }
      }
    }
    q.pop();
    vis[z] = 0;
  }
}
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    init();
    for (int i = 0; i < m; i++) {
      int t1, t2;
      scanf("%d%d", &t1, &t2);
      add_edge(t1, t2, 1);
    }
    for (int i = 1; i <= n; i++) spfa(i);
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) {
        if (dis[i][j] >= inf) dis[i][j] = -1;
        ve[i].push_back(node2(j, dis[i][j]));
        ev[j].push_back(node2(i, dis[i][j]));
      }
    for (int i = 1; i <= n; i++) {
      sort(ve[i].begin(), ve[i].end(), cmp);
      sort(ev[i].begin(), ev[i].end(), cmp);
    }
    int ans1, ans2, ans3, ans4;
    int maxsum = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (i == j || dis[i][j] < 0) continue;
        for (int k1 = 0; k1 < 3; k1++) {
          int v1 = ev[i][k1].to;
          if (v1 == i || v1 == j || dis[v1][i] < 0) continue;
          for (int k2 = 0; k2 < 3; k2++) {
            int v2 = ve[j][k2].to;
            if (v2 == i || v2 == j || v2 == v1 || dis[j][v2] < 0) continue;
            if (dis[v1][i] + dis[i][j] + dis[j][v2] > maxsum) {
              maxsum = dis[v1][i] + dis[i][j] + dis[j][v2];
              ans2 = i;
              ans3 = j;
              ans1 = v1;
              ans4 = v2;
            }
          }
        }
      }
    }
    printf("%d %d %d %d\n", ans1, ans2, ans3, ans4);
  }
  return 0;
}
