#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> v(n), u(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a].push_back(b);
    u[b].push_back(a);
  }
  vector<vector<int>> d(n, vector<int>(n, -1)), d2(n, vector<int>(n, -1));
  for (int i = 0; i < n; i++) {
    queue<int> q;
    d[i][i] = 0;
    vector<bool> used(n);
    used[i] = 1;
    q.push(i);
    while (q.size()) {
      int cur = q.front();
      q.pop();
      for (int j = 0; j < v[cur].size(); j++) {
        if (!used[v[cur][j]]) {
          used[v[cur][j]] = 1;
          d[i][v[cur][j]] = d[i][cur] + 1;
          q.push(v[cur][j]);
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    queue<int> q;
    d2[i][i] = 0;
    vector<bool> used(n);
    used[i] = 1;
    q.push(i);
    while (q.size()) {
      int cur = q.front();
      q.pop();
      for (int j = 0; j < u[cur].size(); j++) {
        if (!used[u[cur][j]]) {
          used[u[cur][j]] = 1;
          d2[i][u[cur][j]] = d2[i][cur] + 1;
          q.push(u[cur][j]);
        }
      }
    }
  }
  vector<set<pair<int, int>>> s1(n), s2(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j || d[i][j] == -1) {
        continue;
      }
      s1[i].insert({-d[i][j], j});
      if (s1[i].size() > 3) {
        s1[i].erase(--s1[i].end());
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j || d2[i][j] == -1) {
        continue;
      }
      s2[i].insert({-d2[i][j], j});
      if (s2[i].size() > 3) {
        s2[i].erase(--s2[i].end());
      }
    }
  }
  int ans1 = -1, ans2 = -1, ans3 = -1, ans4 = -1, ans = -1;
  for (int b = 0; b < n; b++) {
    for (int c = 0; c < n; c++) {
      if (c == b || d[b][c] == -1) {
        continue;
      }
      for (auto it1 = s2[b].begin(); it1 != s2[b].end(); it1++) {
        auto it2 = s1[c].begin();
        int a = it1->second;
        if (a == c || a == b) {
          continue;
        }
        while (it2 != s1[c].end() &&
               (a == it2->second || b == it2->second || c == it2->second)) {
          it2++;
        }
        if (it2 == s1[c].end()) {
          continue;
        }
        int d1 = it2->second;
        int cur = d[a][b] + d[b][c] + d[c][d1];
        if (cur > ans) {
          ans = cur;
          ans1 = a;
          ans2 = b;
          ans3 = c;
          ans4 = d1;
        }
      }
    }
  }
  cout << ans1 + 1 << ' ' << ans2 + 1 << ' ' << ans3 + 1 << ' ' << ans4 + 1
       << endl;
}
