#include <bits/stdc++.h>
using namespace std;
vector<int> adj[3005];
int dp[3005][3005];
int f[3005][5];
int Q[3005];
int ans[4];
int from[3005][4];
int to[3005][4];
int n, m, res;
void bfs(int s) {
  int f = 0;
  int r = 0;
  Q[++r] = s;
  for (int i = 1; i <= n; i++) {
    dp[s][i] = (s != i) ? -1e9 : 0;
  }
  while (r > f) {
    int u = Q[++f];
    for (int v : adj[u]) {
      if (dp[s][v] < 0) {
        dp[s][v] = dp[s][u] + 1;
        Q[++r] = v;
      }
    }
  }
}
void sort_from(int i) {
  for (int j = 0; j <= 3; j++)
    for (int k = j + 1; k <= 3; k++) {
      int u = from[i][j];
      int v = from[i][k];
      if (dp[i][u] < dp[i][v]) {
        swap(from[i][j], from[i][k]);
      }
    }
}
void sort_to(int i) {
  for (int j = 0; j <= 3; j++)
    for (int k = j + 1; k <= 3; k++) {
      int u = to[i][j];
      int v = to[i][k];
      if (dp[u][i] < dp[v][i]) {
        swap(to[i][j], to[i][k]);
      }
    }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) {
    bfs(i);
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      from[i][3] = j;
      to[i][3] = j;
      sort_to(i);
      sort_from(i);
    }
  for (int b = 1; b <= n; b++)
    for (int c = 1; c <= n; c++) {
      if (b == c) continue;
      for (int i = 0; i <= 2; i++)
        for (int j = 0; j <= 2; j++) {
          int a = to[b][i];
          int d = from[c][j];
          if (!a || !d) continue;
          if (a == b || a == c || d == b || d == c || a == d) continue;
          int sum = dp[a][b] + dp[b][c] + dp[c][d];
          if (sum > res) {
            res = sum;
            ans[0] = a;
            ans[1] = b;
            ans[2] = c;
            ans[3] = d;
          }
        }
    }
  for (int i : ans) cout << i << " ";
  return 0;
}
