#include <bits/stdc++.h>
using namespace std;
int n, m, i, one, two;
vector<int> neighs[3001];
vector<int>::iterator it, it2;
int dist[3001];
int distanca[3001][3001];
queue<pair<int, int> > bfs;
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    to[3001], from[3001], cuvajto[3001], cuvajfrom[3001];
int main() {
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d%d", &one, &two);
    neighs[one].push_back(two);
  }
  for (i = 1; i <= n; i++) {
    for (int j = 0; j <= 3000; j++) {
      dist[j] = 100000;
    }
    bfs.push(make_pair(i, 0));
    dist[i] = 0;
    while (!bfs.empty()) {
      pair<int, int> par = bfs.front();
      bfs.pop();
      for (it = neighs[par.first].begin(); it != neighs[par.first].end();
           ++it) {
        int broj = *it;
        if (dist[*it] > par.second + 1) {
          dist[*it] = par.second + 1;
          bfs.push(make_pair(*it, par.second + 1));
        }
      }
    }
    for (int j = 1; j <= n; j++) {
      distanca[i][j] = dist[j];
    }
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      if (dist[j] < 100000) {
        to[j].push(make_pair(dist[j], i));
        if (to[j].size() > 3) {
          to[j].pop();
        }
        from[i].push(make_pair(dist[j], j));
        if (from[i].size() > 3) {
          from[i].pop();
        }
      }
    }
  }
  for (i = 1; i <= 3000; i++) {
    cuvajfrom[i] = from[i];
    cuvajto[i] = to[i];
  }
  int kraj = 0;
  int brojac = 0;
  vector<int> pamti;
  for (i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if ((i == j) || (distanca[i][j] >= 90000)) continue;
      to[i] = cuvajto[i];
      while (!to[i].empty()) {
        from[j] = cuvajfrom[j];
        pair<int, int> par1 = to[i].top();
        to[i].pop();
        while (!from[j].empty()) {
          pair<int, int> par2 = from[j].top();
          from[j].pop();
          if ((par1.second != i) && (par1.second != j) &&
              (par1.second != par2.second) && (i != par2.second) &&
              (j != par2.second)) {
            brojac = distanca[i][j] + par1.first + par2.first;
            if (brojac > kraj) {
              pamti.clear();
              pamti.push_back(par1.second);
              pamti.push_back(i);
              pamti.push_back(j);
              pamti.push_back(par2.second);
              kraj = brojac;
            }
          }
        }
      }
    }
  }
  cout << pamti[0] << " " << pamti[1] << " " << pamti[2] << " " << pamti[3];
  return 0;
}
