#include <bits/stdc++.h>
using namespace std;
int n, m, d[3005][3005], q[3005], best, id, ans, a, b, c, dd;
vector<int> v[3005], s1[3005], s2[3005];
bool cmp(int x, int y) { return d[id][x] > d[id][y]; }
bool cmp2(int x, int y) { return d[x][id] > d[y][id]; }
void go(int nx, int i, int j, int ny) {
  int x = s2[i][nx];
  int y = s1[j][ny];
  if (x != i && x != j && x != y && y != i && y != j) {
    if (ans < d[x][i] + d[i][j] + d[j][y]) {
      ans = d[x][i] + d[i][j] + d[j][y];
      a = x;
      b = i;
      c = j;
      dd = y;
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = (0); i < (m); i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    v[x].push_back(y);
  }
  for (int i = (1); i <= (n); i++) {
    int l = 0, h = 0;
    q[h++] = i;
    for (int j = (1); j <= (n); j++) d[i][j] = -100000;
    d[i][i] = 0;
    while (l < h) {
      int y = q[l++];
      for (int j = (0); j < (v[y].size()); j++) {
        int V = v[y][j];
        if (d[i][V] < 0) {
          d[i][V] = d[i][y] + 1;
          q[h++] = V;
        }
      }
    }
  }
  for (int i = (1); i <= (n); i++) {
    for (int j = (1); j <= (n); j++) s1[i].push_back(j);
    for (int j = (1); j <= (n); j++) s2[i].push_back(j);
    id = i;
    sort(s1[i].begin(), s1[i].end(), cmp);
    sort(s2[i].begin(), s2[i].end(), cmp2);
  }
  for (int i = (1); i <= (n); i++)
    for (int j = (1); j <= (n); j++)
      if (i != j)
        for (int k = (0); k < (4); k++)
          for (int l = (0); l < (4); l++) go(k, i, j, l);
  printf("%d %d %d %d\n", a, b, c, dd);
  scanf("\n");
}
