#include <bits/stdc++.h>
using namespace std;
vector<int> elimina(vector<int> &ar, int u) {
  vector<int> r;
  for (int i = 0; i < int(ar.size()); i++)
    if (ar[i] != u) r.push_back(ar[i]);
  return r;
}
vector<vector<int> > elimina(vector<vector<int> > g, int u, int v) {
  g[u] = elimina(g[u], v);
  g[v] = elimina(g[v], u);
  return g;
}
bool semiconexo(vector<vector<int> > &g, int index) {
  stack<int> s;
  s.push(index);
  int n = int(g.size());
  vector<int> visitado(n, 0);
  visitado[index] = 1;
  while (not s.empty()) {
    int u = s.top();
    s.pop();
    vector<int> &ar = g[u];
    for (int i = 0; i < int(ar.size()); i++) {
      int v = ar[i];
      if (not visitado[v]) {
        visitado[v] = 1;
        s.push(v);
      }
    }
  }
  for (int i = 0; i < n; i++)
    if (int(g[i].size()) > 0 and not visitado[i]) return false;
  return true;
}
void construyecaminominimo(vector<vector<int> > &g, int u, vector<int> &sol) {
  sol.push_back(u);
  vector<int> &ar = g[u];
  for (int i = 0; i < int(ar.size()); i++) {
    int w = ar[i];
    vector<vector<int> > gaux = elimina(g, u, w);
    if (semiconexo(gaux, w)) {
      construyecaminominimo(gaux, w, sol);
      return;
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> camino(m + 1);
  for (int i = 0; i < m + 1; i++) cin >> camino[i];
  vector<vector<int> > g(n + 1);
  bool trobat = false;
  for (int i = m - 1; i >= 0 and not trobat; i--) {
    int u = camino[i];
    int v = camino[i + 1];
    g[u].push_back(v);
    g[v].push_back(u);
    sort(g[u].begin(), g[u].end());
    sort(g[v].begin(), g[v].end());
    vector<int> &ar = g[u];
    for (int j = 0; j < int(ar.size()) and not trobat; j++) {
      int w = ar[j];
      if (w > v) {
        vector<vector<int> > gaux = elimina(g, u, w);
        if (semiconexo(gaux, w)) {
          vector<int> sol;
          for (int ii = 0; ii <= i; ii++) sol.push_back(camino[ii]);
          construyecaminominimo(gaux, w, sol);
          cout << sol[0];
          for (int ii = 1; ii < m + 1; ii++) cout << " " << sol[ii];
          cout << endl;
          trobat = true;
        }
      }
    }
  }
  if (not trobat) cout << "No solution" << endl;
}
