#include <bits/stdc++.h>
using namespace std;
vector<int> mp[3005];
const int inf = 2147483647 / 2;
int from[3005][5], to[3005][5], nfrom[3005], nto[3005], dist[3005][3005];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    mp[a].push_back(b);
  }
  queue<int> p;
  for (int i = 0; i < n; i++) {
    for (int x = 0; x < n; x++) {
      dist[i][x] = inf;
    }
    p.push(i);
    dist[i][i] = 0;
    while (!p.empty()) {
      int v = p.front();
      p.pop();
      for (int x = 0; x < mp[v].size(); x++) {
        int &u = mp[v][x];
        if (dist[i][u] > dist[i][v] + 1) {
          dist[i][u] = dist[i][v] + 1;
          p.push(u);
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    nfrom[i] = 0;
    for (int j = 0; j < n; j++) {
      if (dist[i][j] != inf) {
        from[i][nfrom[i]++] = j;
        for (int k = nfrom[i] - 1;
             k > 0 && dist[i][from[i][k]] > dist[i][from[i][k - 1]]; k--) {
          swap(from[i][k], from[i][k - 1]);
        }
        if (nfrom[i] == 5) nfrom[i]--;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    nto[i] = 0;
    for (int j = 0; j < n; j++) {
      if (dist[j][i] != inf) {
        to[i][nto[i]++] = j;
        for (int k = nto[i] - 1;
             k > 0 && dist[to[i][k]][i] > dist[to[i][k - 1]][i]; k--) {
          swap(to[i][k], to[i][k - 1]);
        }
        if (nto[i] == 5) nto[i]--;
      }
    }
  }
  int best = 0;
  int ans[4];
  for (int b = 0; b < n; b++) {
    for (int c = 0; c < n; c++) {
      if (b != c && dist[b][c] != inf) {
        for (int i = 0; i < nto[b]; i++) {
          int a = to[b][i];
          if (a == c || a == b) continue;
          for (int j = 0; j < nfrom[c]; j++) {
            int d = from[c][j];
            if (d == a || d == b || d == c) continue;
            int res = dist[a][b] + dist[b][c] + dist[c][d];
            if (res > best) {
              best = res;
              ans[0] = a, ans[1] = b, ans[2] = c, ans[3] = d;
            }
          }
        }
      }
    }
  }
  cout << ans[0] + 1 << " " << ans[1] + 1 << " " << ans[2] + 1 << " "
       << ans[3] + 1 << endl;
  return 0;
}
