#include <bits/stdc++.h>
using namespace std;
int n, m;
int p[3005][3005], vis[3005];
int dis, ans1, ans2, ans3, ans4, s1, s2, s3, s4;
vector<int> v[3005];
struct node {
  int num, dis;
};
bool cmp(node x, node y) { return x.dis > y.dis; }
vector<node> to[3005], from[3005];
void solve(int x) {
  queue<int> q;
  memset(vis, 0, sizeof(vis));
  q.push(x);
  vis[x] = 1;
  while (!q.empty()) {
    int t = q.front();
    q.pop();
    vis[t] = 0;
    int len = v[t].size();
    for (int i = 0; i < len; i++) {
      if (p[x][v[t][i]] > p[x][t] + 1) {
        p[x][v[t][i]] = p[x][t] + 1;
        if (!vis[v[t][i]]) {
          vis[v[t][i]] = 1;
          q.push(v[t][i]);
        }
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i != j)
        p[i][j] = 0x3f3f3f3f;
      else
        p[i][j] = 0;
    }
  }
  for (int i = 1; i <= m; i++) {
    int uu, vv;
    scanf("%d%d", &uu, &vv);
    v[uu].push_back(vv);
  }
  for (int i = 1; i <= n; i++) solve(i);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (p[i][j] != 0x3f3f3f3f && i != j) {
        node x;
        x.num = i;
        x.dis = p[i][j];
        to[j].push_back(x);
        x.num = j;
        from[i].push_back(x);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    sort(to[i].begin(), to[i].end(), cmp);
    sort(from[i].begin(), from[i].end(), cmp);
  }
  for (int i = 1; i <= n; i++) {
    s2 = i;
    for (int j = 1; j <= n; j++) {
      s3 = j;
      if (i == j || p[i][j] == 0x3f3f3f3f) continue;
      for (int k = 0; k < 4 && k < to[i].size(); k++) {
        if (i == to[i][k].num || j == to[i][k].num) continue;
        s1 = to[i][k].num;
        for (int d = 0; d < 5 && d < from[j].size(); d++) {
          if (i == from[j][d].num || j == from[j][d].num ||
              s1 == from[j][d].num)
            continue;
          s4 = from[j][d].num;
          if (p[s1][s2] + p[s2][s3] + p[s3][s4] > dis) {
            dis = p[s1][s2] + p[s2][s3] + p[s3][s4];
            ans1 = s1;
            ans2 = s2;
            ans3 = s3;
            ans4 = s4;
          }
        }
      }
    }
  }
  printf("%d %d %d %d\n", ans1, ans2, ans3, ans4);
  return 0;
}
