#include <bits/stdc++.h>
using namespace std;
const int inf = 12345678;
int n, m;
vector<int> nei[4000];
int ans[4000][4000];
void bfs(int x) {
  int i;
  for (i = 0; i < 4000; i++) ans[x][i] = inf;
  queue<int> q;
  q.push(x);
  ans[x][x] = 0;
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    for (i = 0; i < nei[t].size(); i++) {
      if (ans[x][nei[t][i]] > ans[x][t] + 1) {
        ans[x][nei[t][i]] = ans[x][t] + 1;
        q.push(nei[t][i]);
      }
    }
  }
}
int main() {
  cin >> n >> m;
  int a, b;
  int i, res1, res2, res = -1, res3, res4, j, k, o;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    a--;
    b--;
    nei[a].push_back(b);
  }
  for (i = 0; i < n; i++) {
    bfs(i);
  }
  int l1[3][n], l2[3][n];
  for (i = 0; i < n; i++) {
    int m1 = -1, m2 = -1, m3 = -1, i1 = -1, i2 = -1, i3 = -1;
    for (j = 0; j < n; j++) {
      if (i != j && ans[j][i] != inf) {
        if (m1 < ans[j][i]) {
          m3 = m2;
          i3 = i2;
          m2 = m1;
          i2 = i1;
          m1 = ans[j][i];
          i1 = j;
        } else if (m2 < ans[j][i]) {
          m3 = m2;
          i3 = i2;
          m2 = ans[j][i];
          i2 = j;
        } else if (m3 < ans[j][i]) {
          m3 = ans[j][i];
          i3 = j;
        }
      }
    }
    l1[0][i] = i1;
    l1[1][i] = i2;
    l1[2][i] = i3;
    m1 = -1;
    m2 = -1;
    m3 = -1;
    i1 = -1;
    i2 = -1;
    i3 = -1;
    for (j = 0; j < n; j++) {
      if (i != j && ans[i][j] != inf) {
        if (m1 < ans[i][j]) {
          m3 = m2;
          i3 = i2;
          m2 = m1;
          i2 = i1;
          m1 = ans[i][j];
          i1 = j;
        } else if (m2 < ans[i][j]) {
          m3 = m2;
          i3 = i2;
          m2 = ans[i][j];
          i2 = j;
        } else if (m3 < ans[i][j]) {
          m3 = ans[i][j];
          i3 = j;
        }
      }
    }
    l2[0][i] = i1;
    l2[1][i] = i2;
    l2[2][i] = i3;
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (ans[i][j] != inf && i != j) {
        for (k = 0; k < 3; k++) {
          a = l1[k][i];
          for (o = 0; o < 3; o++) {
            b = l2[o][j];
            if (!(a == -1 || b == -1 || a == b || a == j || b == i)) {
              if (ans[a][i] + ans[i][j] + ans[j][b] > res) {
                res = ans[a][i] + ans[i][j] + ans[j][b];
                res1 = a;
                res2 = i;
                res3 = j;
                res4 = b;
              }
            }
          }
        }
      }
    }
  }
  cout << res1 + 1 << " " << res2 + 1 << " " << res3 + 1 << " " << res4 + 1;
  return 0;
}
