#include <bits/stdc++.h>
using namespace std;
int n, m;
const int MAXN = 300;
vector<int> av;
vector<int> ans;
vector<int> ng[MAXN];
bool mark[MAXN][MAXN];
bool dfs(int x, bool cf) {
  if (x > m) return cf;
  int cur = ans[x - 1];
  for (int i = 0; i < ng[cur].size(); i++) {
    if ((!cf && ng[cur][i] < av[x]) || mark[ng[cur][i]][cur]) continue;
    mark[cur][ng[cur][i]] = mark[ng[cur][i]][cur] = true;
    ans[x] = ng[cur][i];
    if (dfs(x + 1, cf || ng[cur][i] != av[x])) return true;
    mark[cur][ng[cur][i]] = mark[ng[cur][i]][cur] = false;
  }
  return false;
}
int main() {
  cin >> n >> m;
  av.resize(m + 1);
  ans.resize(m + 1);
  for (int i = 0; i < m + 1; i++) {
    cin >> av[i];
    av[i]--;
    if (i > 0) {
      ng[av[i]].push_back(av[i - 1]);
      ng[av[i - 1]].push_back(av[i]);
    }
  }
  for (int i = 0; i < n; i++) sort(ng[i].begin(), ng[i].end());
  ans[0] = av[0];
  if (dfs(1, false)) {
    for (int i = 0; i < m + 1; i++) cout << ans[i] + 1 << " ";
    cout << endl;
  } else
    cout << "No solution" << endl;
  return 0;
}
