#include <bits/stdc++.h>
using namespace std;
int N, M;
bool E[3005][3005];
int dis[3005][3005];
vector<pair<int, int> > G[3005], rnk[3005], rrnk[3005];
int pth[4];
int mxd;
void constr(int w, int u, int v, int z) {
  if (w == v || w == z || u == z) return;
  int d = dis[w][u] + dis[u][v] + dis[v][z];
  if (d < mxd) return;
  mxd = d;
  pth[0] = w, pth[1] = u, pth[2] = v, pth[3] = z;
}
bool cmp(pair<int, int> a, pair<int, int> b) {
  return dis[a.first][a.second] > dis[b.first][b.second];
}
void bfs(int S) {
  for (int i = 1; i <= N; i++) dis[S][i] = 1e9;
  dis[S][S] = 0;
  queue<int> Q;
  Q.push(S);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    int d = dis[S][u];
    for (pair<int, int> ei : G[u]) {
      int v = ei.second;
      int dsv = dis[S][v];
      if (dsv > d + 1) {
        dis[S][v] = d + 1;
        Q.push(v);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  int u, v;
  for (int i = 1; i <= M; i++) {
    cin >> u >> v;
    if (u == v || E[u][v]) continue;
    E[u][v] = 1;
    G[u].push_back(make_pair(u, 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 || dis[i][j] == 1e9) continue;
      rnk[i].push_back(make_pair(i, j));
      rrnk[j].push_back(make_pair(i, j));
    }
  }
  for (int i = 1; i <= N; i++) {
    sort(rnk[i].begin(), rnk[i].end(), cmp);
    sort(rrnk[i].begin(), rrnk[i].end(), cmp);
  }
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++)
      if (i != j && dis[i][j] < 1e9) {
        int su = (int)(rrnk[i].size()), sv = (int)(rnk[j].size());
        for (int k = 0; k <= min(2, su - 1); k++)
          for (int l = 0; l <= min(2, sv - 1); l++) {
            int w = rrnk[i][k].first, z = rnk[j][l].second;
            constr(w, i, j, z);
          }
      }
  for (int i = 0; i <= 3; i++) cout << pth[i] << ' ';
  cout << '\n';
  return 0;
}
