#include <bits/stdc++.h>
using namespace std;
int mat[3001][3001], pos[3001][3001], posy[3001][3001];
int mark[3001] = {0}, n;
set<int> adj[3001];
struct node {
  int pos, val;
};
node arr[3001];
bool cmp(node &a, node &b) { return a.val > b.val; }
void bfs(int src) {
  for (int j = 1; j <= n; j++) mark[j] = 0;
  mark[src] = 1;
  set<int>::iterator it;
  queue<int> q;
  q.push(src);
  int ans = 1, curr_push = 1, prev = 1;
  while (!q.empty()) {
    curr_push = 0;
    while (prev--) {
      int curr = q.front();
      q.pop();
      for (it = adj[curr].begin(); it != adj[curr].end(); it++) {
        if (mark[*it]) continue;
        mark[*it] = 1;
        mat[src][*it] = ans;
        q.push(*it);
        curr_push++;
      }
    }
    prev = curr_push;
    ans++;
  }
}
void build() {
  for (int j = 0; j < 3001; j++)
    for (int k = 0; k < 3001; k++) mat[j][k] = -100000007;
  cin >> n;
  int m;
  cin >> m;
  while (m--) {
    int l, r;
    cin >> l >> r;
    adj[l].insert(r);
  }
  for (int j = 1; j <= n; j++) bfs(j);
  for (int j = 1; j <= n; j++) {
    for (int k = 1; k <= n; k++) arr[k].val = mat[j][k], arr[k].pos = k;
    sort(arr + 1, arr + n + 1, cmp);
    for (int k = 1; k <= n; k++) pos[j][k] = arr[k].pos;
  }
  for (int j = 1; j <= n; j++) {
    for (int k = 1; k <= n; k++) arr[k].val = mat[k][j], arr[k].pos = k;
    sort(arr + 1, arr + n + 1, cmp);
    for (int k = 1; k <= n; k++) posy[j][k] = arr[k].pos;
  }
  return;
}
void print() {
  for (int j = 1; j <= n; j++) {
    for (int k = 1; k <= n; k++) cout << mat[j][k] << " ";
    cout << endl;
  }
  return;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  build();
  int ans[5], mx = -100000007 * 4;
  for (int j = 1; j <= n; j++) {
    for (int k = 1; k <= n; k++) {
      if (j == k) continue;
      int curr = mat[j][k];
      int pos1 = posy[j][1];
      int t1 = 2;
      while (pos1 == k || pos1 == j) pos1 = posy[j][t1++];
      int pos2 = pos[k][1];
      int t2 = 2;
      while (pos2 == k || pos2 == j) pos2 = pos[k][t2++];
      if (pos1 == pos2) {
        int x1 = posy[j][t1++], x2 = pos[k][t2++];
        while (x1 == j || x1 == k) x1 = posy[j][t1++];
        while (x2 == j || x2 == k) x2 = pos[k][t2++];
        if (mx < (mat[pos1][j] + mat[k][x2] + curr)) {
          mx = mat[pos1][j] + mat[k][x2] + curr;
          ans[0] = pos1;
          ans[1] = j;
          ans[2] = k;
          ans[3] = x2;
        }
        if (mx < (mat[x1][j] + mat[k][pos2] + curr)) {
          mx = mat[x1][j] + mat[k][pos2] + curr;
          ans[0] = x1;
          ans[1] = j;
          ans[2] = k;
          ans[3] = pos2;
        }
      } else if ((mat[pos1][j] + curr + mat[k][pos2]) > mx) {
        mx = mat[pos1][j] + curr + mat[k][pos2];
        ans[0] = pos1;
        ans[1] = j;
        ans[2] = k;
        ans[3] = pos2;
      }
    }
  }
  cout << ans[0] << " " << ans[1] << " " << ans[2] << " " << ans[3] << endl;
  return 0;
}
