#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, M;
  cin >> N >> M;
  vector<vector<long long> > g(N);
  long long a, b;
  for (long long i = 0; i < M; i++) {
    cin >> a >> b;
    g[a - 1].push_back(b - 1);
  }
  long long INF = (long long)1 << 60;
  vector<vector<long long> > dist(N, vector<long long>(N, INF));
  for (long long i = 0; i < N; i++) {
    dist[i][i] = 0;
    queue<long long> qu;
    qu.push(i);
    while (qu.size()) {
      long long a = qu.front();
      qu.pop();
      for (long long j : g[a]) {
        if (dist[i][j] > dist[i][a] + 1) {
          dist[i][j] = dist[i][a] + 1;
          qu.push(j);
        }
      }
    }
  }
  vector<vector<pair<long long, long long> > > X(N);
  vector<vector<pair<long long, long long> > > Y(N);
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < N; j++) {
      if (dist[i][j] == INF) {
        dist[i][j] = -((long long)1 << 50);
      }
      X[j].emplace_back(dist[i][j], i);
      Y[i].emplace_back(dist[i][j], j);
    }
  }
  for (long long i = 0; i < N; i++) {
    sort(X[i].rbegin(), X[i].rend());
    sort(Y[i].rbegin(), Y[i].rend());
  }
  long long mx = -1;
  vector<long long> res(4);
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < N; j++) {
      if (i != j) {
        for (long long x = 0; x < 3; x++) {
          if (X[i][x].second != i && X[i][x].second != j) {
            for (long long y = 0; y < 3; y++) {
              if (Y[j][y].second != i && Y[j][y].second != j) {
                if (X[i][x].second != Y[j][y].second) {
                  if (mx < dist[i][j] + X[i][x].first + Y[j][y].first) {
                    mx = dist[i][j] + X[i][x].first + Y[j][y].first;
                    res[0] = X[i][x].second;
                    res[1] = i;
                    res[2] = j;
                    res[3] = Y[j][y].second;
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << res[0] + 1 << " " << res[1] + 1 << " " << res[2] + 1 << " "
       << res[3] + 1 << endl;
}
