#include <bits/stdc++.h>
using namespace std;
int cond = 1;
int n, m;
bool e[105][105];
int t[2005];
int ans[2005];
int edges;
int resDfs;
bool v[105];
void dfs(int x) {
  v[x] = true;
  for (int i = 1; i <= n; ++i)
    if (e[x][i]) {
      ++resDfs;
      if (!v[i]) dfs(i);
    }
}
bool connected(int x) {
  memset(v, 0, sizeof(v));
  resDfs = 0;
  dfs(x);
  return resDfs == 2 * edges;
}
void addEdge(int a, int b) {
  ++edges;
  e[a][b] = true;
  e[b][a] = true;
}
void remEdge(int a, int b) {
  --edges;
  e[a][b] = false;
  e[b][a] = false;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m + 1; ++i) {
    scanf("%d", &t[i]);
  }
  edges = 0;
  int last;
  for (last = m; last >= 1; --last) {
    addEdge(t[last], t[last + 1]);
    bool got = false;
    for (int j = t[last + 1] + 1; j <= n; ++j)
      if (e[t[last]][j]) {
        remEdge(t[last], j);
        if (connected(j)) {
          t[last + 1] = j;
          got = true;
          break;
        }
        addEdge(t[last], j);
      }
    if (got) break;
  }
  if (last == 0) {
    printf("No solution\n");
    return 0;
  }
  ++last;
  for (; last <= m; ++last) {
    for (int j = 1; j <= n; ++j)
      if (e[t[last]][j]) {
        remEdge(t[last], j);
        if (connected(j)) {
          t[last + 1] = j;
          break;
        }
        addEdge(t[last], j);
      }
  }
  for (int i = 1; i <= m; ++i) printf("%d ", t[i]);
  printf("%d\n", t[m + 1]);
  return 0;
}
