#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100;
int low[MAXN], dfn[MAXN];
vector<int> E[MAXN];
set<pair<int, int> > keyE;
void tarjan(int u, int deep) {
  low[u] = dfn[u] = deep;
  for (vector<int>::iterator it = E[u].begin(); it != E[u].end(); it++) {
    int v = *it;
    if (dfn[v] == 0) {
      tarjan(v, deep + 1);
      low[u] = min(low[u], low[v]);
      if (low[v] > low[u]) {
        keyE.insert(make_pair(u, v));
      }
    } else if (dfn[v] != dfn[u] - 1) {
      low[u] = min(low[u], dfn[v]);
    }
  }
}
void component(int n) {
  keyE.clear();
  fill(dfn, dfn + n, 0);
  for (int i = 0; i < n; i++) {
    if (dfn[i] == 0) {
      tarjan(i, 1);
    }
  }
}
int main() {
  for (int n, m; ~scanf("%d%d", &n, &m);) {
    for (int i = 0; i < n; i++) {
      E[i].clear();
    }
    vector<int> path;
    path.resize(m + 1);
    for (int i = 0; i <= m; i++) {
      scanf("%d", &path[i]);
      path[i]--;
    }
    for (int num = m; num >= 0; num--) {
      if (num == 0) {
        puts("No solution");
        break;
      }
      int u = path[num - 1];
      int v = path[num];
      E[u].push_back(v);
      E[v].push_back(u);
      sort(E[u].begin(), E[u].end());
      sort(E[v].begin(), E[v].end());
      component(n);
      for (vector<int>::iterator it = upper_bound(E[u].begin(), E[u].end(), v);
           it != E[u].end(); it++) {
        v = *it;
        if (keyE.count(make_pair(u, v)) == 0 &&
            keyE.count(make_pair(v, u)) == 0) {
          E[u].erase(lower_bound(E[u].begin(), E[u].end(), v));
          E[v].erase(lower_bound(E[v].begin(), E[v].end(), u));
          path.resize(num);
          path.push_back(v);
          vector<int> tail;
          while ((int)path.size() > num) {
            v = path.back();
            if (E[v].empty()) {
              tail.push_back(v);
              path.pop_back();
            } else {
              int w = E[v][0];
              path.push_back(w);
              E[w].erase(lower_bound(E[w].begin(), E[w].end(), v));
              E[v].erase(E[v].begin());
            }
          }
          path.insert(path.end(), tail.rbegin(), tail.rend());
          for (vector<int>::iterator pit = path.begin(); pit != path.end();
               pit++) {
            if (pit != path.begin()) {
              putchar(' ');
            }
            printf("%d", *pit + 1);
          }
          puts("");
          num = 0;
          break;
        }
      }
    }
  }
  return 0;
}
