#include <bits/stdc++.h>
using namespace std;
int n, m;
bool a[110][110];
int stk[2010];
int seq[2010];
bool reach;
bool ok;
void input() {
  memset(a, 0, sizeof(a));
  for (int i = 0; i <= m; i++) {
    scanf("%d", seq + i);
    if (i) a[seq[i]][seq[i - 1]] = a[seq[i - 1]][seq[i]] = true;
  }
}
bool dfs(int x, int num) {
  if (num == m + 1) {
    if (!reach)
      reach = true;
    else
      ok = true;
    return true;
  }
  if (reach) {
    for (int i = 1; i <= n; i++)
      if (a[x][i]) {
        stk[num] = i;
        a[x][i] = a[i][x] = false;
        if (dfs(i, num + 1)) return true;
        a[x][i] = a[i][x] = true;
      }
  } else {
    a[x][seq[num]] = a[seq[num]][x] = false;
    stk[num] = seq[num];
    dfs(seq[num], num + 1);
    if (ok) return true;
    a[x][seq[num]] = a[seq[num]][x] = true;
    for (int i = seq[num] + 1; i <= n; i++)
      if (a[x][i]) {
        stk[num] = i;
        a[x][i] = a[i][x] = false;
        if (dfs(i, num + 1)) return true;
        a[x][i] = a[i][x] = true;
      }
  }
  return false;
}
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    input();
    ok = reach = false;
    stk[0] = seq[0];
    if (!dfs(seq[0], 1))
      printf("No solution\n");
    else {
      for (int i = 0; i <= m; i++) printf("%d%c", stk[i], i == m ? '\n' : ' ');
    }
  }
  return 0;
}
