#include <bits/stdc++.h>
using namespace std;
double esp = 1e-11;
const double PI = acos(-1.0);
const long long int INF = 0x3f3f3f3f;
const int maxn = 3010;
vector<int> node[5100];
int d[maxn][maxn];
queue<int> q;
int in[maxn];
vector<pair<int, int> > fp1[maxn], fp2[maxn];
vector<pair<int, int> >::reverse_iterator it1, it2;
int main() {
  memset(d, 0x3f, sizeof(d));
  int n, m;
  scanf("%d%d", &n, &m);
  for (int x = 1; x <= n; x++)
    node[x].clear(), d[x][x] = 0, fp1[x].clear(), fp2[x].clear();
  int u, v;
  for (int x = 1; x <= m; x++) {
    scanf("%d%d", &u, &v);
    node[u].push_back(v);
  }
  memset(in, 0, sizeof(in));
  while (!q.empty()) q.pop();
  int t, len;
  for (int x = 1; x <= n; x++) {
    while (!q.empty()) q.pop();
    q.push(x);
    in[x] = 1;
    while (!q.empty()) {
      t = q.front();
      q.pop();
      len = node[t].size();
      for (int y = 0; y < len; y++)
        if (d[x][t] + 1 < d[x][node[t][y]]) {
          d[x][node[t][y]] = d[x][t] + 1;
          if (in[node[t][y]] == 0) {
            in[node[t][y]] = 1;
            q.push(node[t][y]);
          }
        }
      in[t] = 0;
    }
  }
  memset(fp1, 0, sizeof(fp1));
  memset(fp2, 0, sizeof(fp2));
  for (int x = 1; x <= n; x++)
    for (int y = 1; y <= n; y++)
      if (x != y && d[x][y] != INF) {
        fp1[y].push_back(make_pair(d[x][y], x));
        fp2[x].push_back(make_pair(d[x][y], y));
      }
  for (int x = 1; x <= n; x++)
    sort((fp1[x]).begin(), (fp1[x]).end()),
        sort((fp2[x]).begin(), (fp2[x]).end());
  int a = 0, b = 0, c = 0, g = 0, ans = 0, s1, s2;
  for (int x = 1; x <= n; x++)
    for (int y = 1; y <= n; y++)
      if (x != y) {
        for (it1 = fp1[x].rbegin(), s1 = 0; it1 != fp1[x].rend() && s1 <= 2;
             it1++, s1++)
          for (it2 = fp2[y].rbegin(), s2 = 0; it2 != fp2[y].rend() && s2 <= 2;
               it2++, s2++)
            if (it1->second != y && it1->second != it2->second &&
                it2->second != x &&
                d[it1->second][x] + d[x][y] + d[y][it2->second] > ans &&
                d[it1->second][x] + d[x][y] + d[y][it2->second] < INF) {
              ans = d[it1->second][x] + d[x][y] + d[y][it2->second];
              a = it1->second;
              b = x;
              c = y;
              g = it2->second;
            }
      }
  printf("%d %d %d %d\n", a, b, c, g);
  return 0;
}
