#include <bits/stdc++.h>
using namespace std;
const int N = 2013;
int n, m, seq[N], deg[N];
bool mark[N];
pair<int, int> e[N];
vector<int> path;
vector<pair<int, int> > adj[N];
bool check(int u, int v) {
  int res = (adj[u].size() & 1 ^ 1) + (adj[v].size() & 1 ^ 1);
  for (int i = 0; i < n; i++)
    if (i != u && i != v) res += adj[i].size() & 1;
  return res <= 2;
}
void dfs(int v) {
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i].first, t = adj[v][i].second;
    if (!mark[t]) {
      mark[t] = true;
      dfs(u);
    }
  }
  path.push_back(v);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < m + 1; i++) {
    cin >> seq[i];
    seq[i]--;
  }
  for (int i = m - 1; i >= 0; i--) {
    adj[seq[i + 1]].push_back(pair<int, int>(seq[i], i));
    for (int j = adj[seq[i + 1]].size() - 1;
         j && adj[seq[i + 1]][j] < adj[seq[i + 1]][j - 1]; j--)
      swap(adj[seq[i + 1]][j], adj[seq[i + 1]][j - 1]);
    adj[seq[i]].push_back(pair<int, int>(seq[i + 1], i));
    for (int j = adj[seq[i]].size() - 1;
         j && adj[seq[i]][j] < adj[seq[i]][j - 1]; j--)
      swap(adj[seq[i]][j], adj[seq[i]][j - 1]);
    for (int j = 0; j < adj[seq[i]].size(); j++) {
      int u = adj[seq[i]][j].first;
      if (u > seq[i + 1]) {
        memset(mark, 0, sizeof mark);
        path.clear();
        mark[adj[seq[i]][j].second] = true;
        dfs(u);
        if (path.size() + i == m) {
          for (int j = 0; j <= i; j++) cout << seq[j] + 1 << ' ';
          for (int j = path.size() - 1; j >= 0; j--) cout << path[j] + 1 << ' ';
          cout << '\n';
          return 0;
        }
      }
    }
  }
  cout << "No solution\n";
  return 0;
}
