func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 3e3 + 1;   struct node {     int w, x, y, z;   };   queue<int> q;   vector<int> g[N], rg[N];   int d[N][N], rd[N][N], vis[N];   vector<pair<int, int>> fg[N], frg[N];   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     for (int i = 1; i <= m; i++) {       int u, v;       cin >> u >> v;       g[u].push_back(v);       rg[v].push_back(u);     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         vis[j] = 0;         d[i][j] = n + 1;       }       vis[i] = 1;       q.push(i);       d[i][i] = 0;       while (!q.empty()) {         int v = q.front();         q.pop();         for (auto u : g[v]) {           if (vis[u]) continue;           vis[u] = 1;           q.push(u);           d[i][u] = d[i][v] + 1;         }       }       for (int j = 1; j <= n; j++) {         if (j == i) continue;         if (d[i][j] != n + 1) fg[i].push_back({d[i][j], j});       }       sort(fg[i].begin(), fg[i].end());       for (int j = 1; j <= n; j++) {         vis[j] = 0;         rd[i][j] = n + 1;       }       vis[i] = 1;       q.push(i);       rd[i][i] = 0;       while (!q.empty()) {         int v = q.front();         q.pop();         for (auto u : rg[v]) {           if (vis[u]) continue;           vis[u] = 1;           q.push(u);           rd[i][u] = rd[i][v] + 1;         }       }       for (int j = 1; j <= n; j++) {         if (j == i) continue;         if (rd[i][j] != n + 1) frg[i].push_back({rd[i][j], j});       }       sort(frg[i].begin(), frg[i].end());     }     int ans = 0;     node A;     for (int b = 1; b <= n; b++) {       for (int c = 1; c <= n; c++) {         if (b == c || d[b][c] == n + 1) continue;         int ans1 = 0, z = 0;         node B;         int sz1 = frg[b].size(), sz2 = fg[c].size();         for (int j = sz1 - 1; j >= max(z, sz1 - 3); j--) {           int a = frg[b][j].second;           for (int k = sz2 - 1; k >= max(z, sz2 - 3); k--) {             int dd = fg[c][k].second;             if (a == c || dd == b || a == dd) continue;             int ans2 = d[b][c] + rd[b][a] + d[c][dd];             node C;             C.w = a;             C.x = b;             C.y = c;             C.z = dd;             if (ans2 > ans1) {               ans1 = ans2;               B = C;             }           }         }         if (ans1 > ans) {           ans = ans1;           A = B;         }       }     }     cout << A.w <<     << A.x <<     << A.y <<     << A.z <<   n ;     return 0;   }   