#include <bits/stdc++.h>
using namespace std;
const bool print = true;
const int MAXN = 4111;
vector<int> kraw[2][MAXN];
int odl[2][MAXN][MAXN];
int n;
vector<pair<int, int> > farthest[2][MAXN];
void bfs(int start, int ord) {
  for (int i = (1); i <= (n); i++) odl[ord][start][i] = MAXN * 69;
  odl[ord][start][start] = 0;
  queue<int> Q;
  Q.push(start);
  while (!Q.empty()) {
    int a = Q.front();
    Q.pop();
    farthest[ord][start].emplace_back(odl[ord][start][a], a);
    for (auto b : kraw[ord][a]) {
      if (odl[ord][start][b] <= odl[ord][start][a] + 1) continue;
      odl[ord][start][b] = odl[ord][start][a] + 1;
      Q.push(b);
    }
  }
  sort((farthest[ord][start]).begin(), (farthest[ord][start]).end());
  reverse((farthest[ord][start]).begin(), (farthest[ord][start]).end());
}
int main() {
  int m;
  scanf("%d%d", &n, &m);
  for (int i = (1); i <= (m); i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    kraw[1][a].push_back(b);
    kraw[0][b].push_back(a);
  }
  for (int iii = (0); iii <= (1); iii++)
    for (int st = (1); st <= (n); st++) bfs(st, iii);
  int wyn1 = 0, wyn2 = 0, wyn3 = 0, wyn4 = 0;
  int suma = 0;
  for (int w2 = (1); w2 <= (n); w2++) {
    for (int w3 = (1); w3 <= (n); w3++) {
      if (w2 == w3) continue;
      int obsuma = odl[1][w2][w3];
      if (obsuma > MAXN) continue;
      int w1 = 0, w4 = 0;
      for (auto it : farthest[0][w2]) {
        if (it.second == w2 || it.second == w3 || it.second == w4) continue;
        w1 = it.second, obsuma += it.first;
        break;
      }
      for (auto it : farthest[1][w3]) {
        if (it.second == w2 || it.second == w3 || it.second == w1) continue;
        w4 = it.second, obsuma += it.first;
        break;
      }
      if (w1 != 0 && w4 != 0 && obsuma > suma)
        suma = obsuma, wyn1 = w1, wyn2 = w2, wyn3 = w3, wyn4 = w4;
      obsuma = odl[1][w2][w3];
      w1 = 0, w4 = 0;
      for (auto it : farthest[1][w3]) {
        if (it.second == w2 || it.second == w3 || it.second == w1) continue;
        w4 = it.second, obsuma += it.first;
        break;
      }
      for (auto it : farthest[0][w2]) {
        if (it.second == w2 || it.second == w3 || it.second == w4) continue;
        w1 = it.second, obsuma += it.first;
        break;
      }
      if (w1 != 0 && w4 != 0 && obsuma > suma)
        suma = obsuma, wyn1 = w1, wyn2 = w2, wyn3 = w3, wyn4 = w4;
    }
  }
  printf("%d %d %d %d\n", wyn1, wyn2, wyn3, wyn4);
}
