#include <bits/stdc++.h>
using namespace std;
int a[2005], G[105][105];
int ans[2005], n, m;
bool dfs(int u, int d, int c) {
  if (d >= m) return true;
  int v;
  if (c)
    v = 1;
  else
    v = a[d + 1] + 1;
  for (; v <= n; v++) {
    if (G[u][v]) {
      G[u][v] = G[v][u] = 0;
      if (dfs(v, d + 1, 1)) {
        ans[d + 1] = v;
        return true;
      }
      G[u][v] = G[v][u] = 1;
    }
  }
  return false;
}
void print_ans() {
  for (int i = 0; i <= m; i++) {
    if (!ans[i])
      printf("%d ", a[i]);
    else
      printf("%d ", ans[i]);
  }
  printf("\n");
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= m; i++) scanf("%d", &a[i]);
  int c = 0;
  for (int i = m; i > 0; i--) {
    G[a[i]][a[i - 1]] = G[a[i - 1]][a[i]] = 1;
    if (dfs(a[i - 1], i - 1, 0)) {
      ans[i - 1] = a[i - 1];
      print_ans();
      c = 1;
      break;
    }
  }
  if (!c) puts("No solution\n");
}
