#include <bits/stdc++.h>
using namespace std;
int n, m;
int in[2010];
int ans[2010];
vector<int> v[2010];
bool mark[2010][2010];
bool flag;
void Dfs(int cur, bool f) {
  if (cur > m && ans[m] == ans[0] && f) {
    flag = 1;
    for (int i = 0; i < m; i++) printf("%d ", ans[i]);
    printf("%d\n", ans[m]);
    return;
  };
  if (flag == 1) return;
  int x, y;
  x = ans[cur - 1];
  for (int i = 0; i < v[x].size(); i++) {
    int y = v[x][i];
    ans[cur] = y;
    if (mark[x][y]) continue;
    if (f == 0) {
      if (y > in[cur]) {
        mark[x][y] = mark[y][x] = 1;
        Dfs(cur + 1, 1);
        mark[x][y] = mark[y][x] = 0;
      } else if (y == in[cur]) {
        mark[x][y] = mark[y][x] = 1;
        Dfs(cur + 1, 0);
        mark[x][y] = mark[y][x] = 0;
      }
    } else {
      mark[x][y] = mark[y][x] = 1;
      Dfs(cur + 1, 1);
      mark[x][y] = mark[y][x] = 0;
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i <= m; i++) scanf("%d", &in[i]);
  for (int i = 1; i <= m; i++) {
    v[in[i]].push_back(in[i - 1]);
    v[in[i - 1]].push_back(in[i]);
  }
  for (int i = 1; i <= n; i++) sort(v[i].begin(), v[i].end());
  memset(mark, 0, sizeof(mark));
  ans[0] = in[0];
  flag = 0;
  Dfs(1, 0);
  if (!flag) printf("No solution\n");
}
