#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > gr(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    gr[a].push_back(b);
  }
  vector<vector<int> > d(n, vector<int>(n, -1));
  for (int i = 0; i < n; i++) {
    d[i][i] = 0;
    queue<int> q;
    q.push(i);
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (int j = 0; j < gr[v].size(); j++) {
        int u = gr[v][j];
        if (d[i][u] == -1) {
          q.push(u);
          d[i][u] = d[i][v] + 1;
        }
      }
    }
  }
  vector<vector<pair<int, int> > > in(n, vector<pair<int, int> >(n));
  vector<vector<pair<int, int> > > out(n, vector<pair<int, int> >(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++)
      if (d[i][j] != -1 && i != j) {
        in[j][i] = make_pair(d[i][j], i);
        out[i][j] = make_pair(d[i][j], j);
      }
    sort(out[i].rbegin(), out[i].rend());
  }
  for (int i = 0; i < n; i++) sort(in[i].rbegin(), in[i].rend());
  int ans = 0;
  vector<int> res(4);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i == j || d[i][j] == -1) continue;
      int cur = d[i][j];
      for (int a = 0; a < min(5, (int)in[i].size()); a++)
        for (int b = 0; b < min(5, (int)out[j].size()); b++) {
          auto v = in[i][a];
          auto u = out[j][b];
          if (d[v.second][i] == -1 || d[j][u.second] == -1) continue;
          if (i != u.second && i != v.second && j != u.second &&
              j != v.second && v.second != u.second) {
            cur = d[i][j] + v.first + u.first;
            if (cur > ans) {
              ans = cur;
              res = {v.second, i, j, u.second};
            }
          }
        }
    }
  for (int i = 0; i < 4; i++) cout << res[i] + 1 << " ";
  cout << endl;
  return 0;
}
