#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;
const int maxm = 4000 + 10;
int n, m, ord[maxm], ans[maxm], head[maxn], esum;
bool findans, graph[maxn][maxn];
struct {
  int ending, prev;
} e[maxm];
void ins_edge(int x, int y) {
  e[++esum].ending = y, e[esum].prev = head[x], head[x] = esum;
}
void init() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= m; ++i) scanf("%d", ord + i);
  for (int i = 1; i <= m; ++i)
    graph[ord[i - 1]][ord[i]] = graph[ord[i]][ord[i - 1]] = 1;
  esum = 1;
  for (int i = 1; i <= n; ++i)
    for (int j = n; j; --j)
      if (graph[i][j]) ins_edge(i, j);
}
void check() {
  findans = 1;
  for (int i = 0; i < m; ++i) printf("%d ", ans[i]);
  printf("%d\n", ans[m]);
}
void search(int x, bool larger) {
  if (x > m) {
    if (larger) check();
    return;
  }
  for (int i = head[ans[x - 1]]; i && !findans; i = e[i].prev)
    if (graph[ans[x - 1]][e[i].ending]) {
      ans[x] = e[i].ending;
      graph[ans[x - 1]][e[i].ending] = graph[e[i].ending][ans[x - 1]] = 0;
      if (larger || (!larger && e[i].ending >= ord[x]))
        search(x + 1, larger | (e[i].ending > ord[x]));
      graph[ans[x - 1]][e[i].ending] = graph[e[i].ending][ans[x - 1]] = 1;
    }
}
int main() {
  init();
  ans[0] = ord[0];
  search(1, 0);
  if (!findans) puts("No solution");
  return 0;
}
