#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v, ans;
int root;
bool e[105][105];
bool dfs(int now, int dep, int type) {
  if (dep == m) {
    if (type == 0)
      return 0;
    else {
      for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
      return 1;
    }
  }
  if (type == 1) {
    for (int i = 1; i <= n; i++) {
      if (e[now][i]) {
        e[now][i] = e[i][now] = 0;
        ans.push_back(i);
        if (dfs(i, dep + 1, 1)) return 1;
        e[now][i] = e[i][now] = 1;
        ans.pop_back();
      }
    }
  } else {
    for (int i = v[dep + 1]; i <= n; i++) {
      if (!e[now][i]) continue;
      e[now][i] = e[i][now] = 0;
      ans.push_back(i);
      if (i == v[dep + 1]) {
        if (dfs(i, dep + 1, 0)) return 1;
      } else {
        if (dfs(i, dep + 1, 1)) return 1;
      }
      e[now][i] = e[i][now] = 1;
      ans.pop_back();
    }
  }
  return 0;
}
int main() {
  cin >> n >> m;
  cin >> root;
  int last = root;
  v.push_back(root);
  for (int i = 0; i < m; i++) {
    int now;
    scanf("%d", &now);
    v.push_back(now);
    e[now][last] = e[last][now] = 1;
    last = now;
  }
  ans.push_back(root);
  if (!dfs(root, 0, 0)) printf("No solution\n");
  return 0;
}
