func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 9;   const double eps = 1e-5;   const int maxN = 2e3 + 10;   const int inf = 1e9;   int n, m;   vector<pair<int, int> > a[maxN];   int vis[maxN], c[maxN];   vector<int> pat;   inline void dfs(int v, int f = -1) {     for (int i = 0; i < a[v].size(); i++) {       if (a[v][i].first <= f) continue;       if (!vis[a[v][i].second]) {         vis[a[v][i].second] = 1;         dfs(a[v][i].first);       }     }     pat.push_back(v);   }   inline void init() {     cin >> n >> m;     for (int i = 0; i < m + 1; i++) {       cin >> c[i];       c[i]--;     }     for (int i = 1; i < m + 1; i++) {       int v = c[i - 1], u = c[i];       a[v].push_back(make_pair(u, i - 1));       a[u].push_back(make_pair(v, i - 1));     }     for (int i = 0; i < n; i++) sort(a[i].begin(), a[i].end());   }   inline void solve() {     for (int i = m - 1; i >= 0; i--) {       memset(vis, 0, sizeof vis);       pat.clear();       for (int j = 0; j < i; j++) vis[j] = 1;       dfs(c[i], c[i + 1]);       if (i + pat.size() == m + 1) {         reverse(pat.begin(), pat.end());         for (int j = 0; j < i; j++) cout << c[j] + 1 <<    ;         for (int j = 0; j < pat.size(); j++) cout << pat[j] + 1 <<    ;         cout << endl;         return;       }     }     cout <<  No solution  << endl;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie();     cout.tie();     init();     solve();     return 0;   }   