#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) { return (a > b) ? a : b; }
long long min(long long a, long long b) { return (a < b) ? a : b; }
void ain(vector<long long>& a) {
  for (long long i = 0; i < a.size(); i++) cin >> a[i];
}
long long Ceil(double d) { return ((long long)d == d) ? d : d + 1; }
long long check(long long mid, long long k, vector<long long>& a) {
  long long n = a.size();
  vector<long long> b(n, 1);
  for (long long i = 0; i < n; i++) {
    if (a[i] < mid) b[i] = -1;
  }
  vector<long long> Min(n, 1e18);
  long long sum = 0;
  long long Max = -1;
  for (long long i = 0; i < n; i++) {
    sum += b[i];
    if (i == 0)
      Min[i] = sum;
    else
      Min[i] = min(Min[i - 1], sum);
    if (i >= k - 1) {
      long long Min1 = ((i - k >= 0) ? Min[i - k] : 0);
      Max = max(Max, sum - Min1);
    }
  }
  return Max;
}
long long n, m;
vector<vector<long long> > a;
vector<long long> ans;
vector<vector<long long> > used;
vector<long long> V;
bool answered = false;
void dfs(long long c, long long ind, bool done) {
  ans[ind] = c;
  if (ind == m) {
    if (!done) return;
    if (c != V[0]) return;
    for (long long i = 0; i < m + 1; i++) cout << ans[i] + 1 << " ";
    cout << endl;
    answered = 1;
    return;
  }
  for (long long i = 0; i < a[c].size(); i++) {
    long long v = a[c][i];
    if (!used[c][v] and !used[v][c]) {
      if (!done) {
        used[c][v] = 1;
        if (v > V[ind + 1]) {
          dfs(v, ind + 1, true);
          if (answered) return;
        } else if (v == V[ind + 1]) {
          dfs(v, ind + 1, false);
          if (answered) return;
        }
        used[c][v] = 0;
      } else {
        used[c][v] = 1;
        dfs(v, ind + 1, done);
        if (answered) return;
        used[c][v] = 0;
      }
    }
  }
}
int32_t main() {
  cin >> n >> m;
  vector<long long> c;
  a.assign(n, c);
  long long prev = -1;
  ans.assign(m + 1, 0);
  vector<long long> C(n, 0);
  used.assign(n, C);
  for (long long i = 0; i < m + 1; i++) {
    long long x;
    cin >> x;
    x--;
    V.push_back(x);
    if (prev != -1) {
      a[prev].push_back(x);
      a[x].push_back(prev);
    }
    prev = x;
  }
  for (long long i = 0; i < n; i++) sort(a[i].begin(), a[i].end());
  dfs(V[0], 0, 0);
  if (!answered) {
    cout << "No solution\n";
  }
  return 0;
}
