#include <bits/stdc++.h>
using namespace std;
int n, m, sum;
int a[2101], first[111], ans[2101];
bool v[2101 * 2], flag;
struct E {
  int next;
  int to;
  void add(int x, int y) {
    next = first[x];
    to = y;
    first[x] = sum;
  }
} e[2101 * 2];
struct NO {
  int w;
  int num;
  bool operator<(const NO b) const { return w > b.w; }
};
void print() {
  for (int i = 1; i <= m + 1; i++) printf("%d ", ans[i]);
  exit(0);
}
void dfs(int x, int loc) {
  ans[loc] = x;
  if (loc == m + 1) {
    if (flag) print();
    return;
  }
  priority_queue<NO> q;
  while (!q.empty()) q.pop();
  for (int i = first[x]; i; i = e[i].next) q.push((NO){e[i].to, i});
  while (!q.empty()) {
    NO now = q.top();
    q.pop();
    int i = now.num;
    if (v[i & 1 ? i : i - 1]) continue;
    int to = e[i].to;
    bool bj = 0;
    if (to < a[loc + 1] && !flag) continue;
    if (to > a[loc + 1] && !flag) {
      flag = 1;
      bj = 1;
    }
    v[i & 1 ? i : i - 1] = 1;
    dfs(to, loc + 1);
    v[i & 1 ? i : i - 1] = 0;
    if (bj) flag = 0;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m + 1; i++) scanf("%d", a + i);
  for (int i = 2; i <= m + 1; i++) {
    e[++sum].add(a[i - 1], a[i]);
    e[++sum].add(a[i], a[i - 1]);
  }
  dfs(a[1], 1);
  printf("No solution");
  return 0;
}
