#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> g[100];
int ord[3003];
bool vis[100];
int pos[100] = {};
int deg[100] = {};
int getHash(int u, int v) { return (min(u, v) << 7) | max(u, v); }
void dfs(int v, int p) {
  vis[v] = true;
  for (int to : g[v])
    if (to != p && !vis[to]) {
      dfs(to, v);
    }
}
void eraseEdge(int x, int y) {
  g[x].erase(find(g[x].begin(), g[x].end(), y));
  g[y].erase(find(g[y].begin(), g[y].end(), x));
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (int)(m + 1); ++i) scanf("%d", ord + i), --ord[i];
  for (int i = m - 1; i >= 0; --i) {
    int from = ord[i];
    int to = ord[i + 1];
    g[from].push_back(to);
    g[to].push_back(from);
    int p = -1;
    if (i) p = ord[i - 1];
    sort(g[from].begin(), g[from].end());
    for (int x : g[from])
      if (x > to && x != p) {
        for (int j = 0; j < (int)(n); ++j) vis[j] = g[j].empty();
        dfs(x, from);
        bool ok = true;
        vis[from] = true;
        for (int j = 0; j < (int)(n); ++j)
          if (!vis[j]) {
            ok = false;
            break;
          }
        if (!ok) continue;
        ord[i + 1] = x;
        eraseEdge(from, x);
        for (int j = 0; j < (int)(n); ++j) sort(g[j].begin(), g[j].end());
        for (int j = 0; j < (int)(n); ++j) deg[j] = (int)g[j].size();
        for (int j = i + 2; j <= m; ++j) ord[j] = -2;
        for (i += 2; i <= m; ++i) {
          for (int y : g[x]) {
            for (int j = 0; j < (int)(n); ++j) vis[j] = deg[j] == 0;
            dfs(y, x);
            vis[x] = true;
            bool ok = true;
            for (int j = 0; j < (int)(n); ++j)
              if (!vis[j]) {
                ok = false;
                break;
              }
            if (!ok) continue;
            eraseEdge(x, y);
            --deg[x];
            --deg[y];
            ord[i] = x = y;
            break;
          }
        }
        for (int j = 0; j < (int)(m + 1); ++j) printf("%d ", ord[j] + 1);
        printf("\n");
        return 0;
      }
  }
  printf("No solution\n");
  return 0;
}
