#include <bits/stdc++.h>
using namespace std;
const int NMAX = 100000;
const int INF = 1000000000;
const long double EPS = 1e-9;
int n, m, fs;
int a[100][100];
int path[3000];
int cur[3000];
int szc = 0;
bool used[100];
bool can(int u, int v) {
  if (u == v) return true;
  used[u] = true;
  for (int i = 0; i < int(n); i++)
    if (a[u][i] && !used[i])
      if (can(i, v)) return true;
  return false;
}
bool find_mn(int idx) {
  if (idx == m) return true;
  int v = cur[idx];
  for (int i = 0; i < int(n); i++)
    if (a[v][i]) {
      a[v][i] = a[i][v] = 0;
      memset(used, 0, sizeof used);
      if (can(i, fs)) {
        cur[idx + 1] = i;
        if (find_mn(idx + 1)) return true;
      }
      a[i][v] = a[v][i] = 1;
    }
  return false;
}
bool solve(int idx) {
  cur[idx] = path[idx];
  if (idx == m) return false;
  a[path[idx]][path[idx + 1]] = a[path[idx + 1]][path[idx]] = 0;
  if (!solve(idx + 1)) {
    a[path[idx]][path[idx + 1]] = a[path[idx + 1]][path[idx]] = 1;
    for (int u = path[idx + 1] + 1; u < n; u++) {
      if (a[path[idx]][u]) {
        a[path[idx]][u] = a[u][path[idx]] = 0;
        memset(used, 0, sizeof used);
        if (can(u, fs)) {
          cur[idx + 1] = u;
          if (find_mn(idx + 1)) return true;
        }
        a[path[idx]][u] = a[u][path[idx]] = 1;
      }
    }
  } else
    return true;
  return false;
}
int main() {
  scanf("%d %d\n", &n, &m);
  for (int i = 0; i < int(m + 1); i++) {
    scanf("%d", &path[i]);
    path[i]--;
    if (i > 0) a[path[i - 1]][path[i]] = a[path[i]][path[i - 1]] = 1;
  }
  fs = path[0];
  if (solve(0)) {
    for (int i = 0; i < int(m + 1); i++) printf("%d ", cur[i] + 1);
    puts("");
  } else
    puts("No solution");
  return 0;
}
