#include <bits/stdc++.h>
using namespace std;
vector<int64_t> v, v2;
int64_t w[105][105];
bool fin;
int64_t n;
void dfs(int64_t x, int64_t now, bool isbig) {
  v2.push_back(x);
  if (now == v.size() && isbig) return fin = true, void();
  if (now == v.size()) {
    v2.pop_back();
    return;
  }
  if (isbig) {
    for (int64_t i = 1; i <= n; i++)
      if (w[x][i]) {
        w[x][i]--;
        w[i][x]--;
        dfs(i, now + 1, isbig);
        if (fin) return;
        w[x][i]++;
        w[i][x]++;
      }
  } else {
    for (int64_t i = v[now]; i <= n; i++)
      if (w[x][i]) {
        if (i == v[now]) {
          w[x][i]--;
          w[i][x]--;
          dfs(i, now + 1, isbig);
          if (fin) return;
          w[x][i]++;
          w[i][x]++;
        } else {
          w[x][i]--;
          w[i][x]--;
          dfs(i, now + 1, true);
          if (fin) return;
          w[x][i]++;
          w[i][x]++;
        }
      }
  }
  v2.pop_back();
}
int32_t main() {
  {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
  };
  int64_t m, a, b;
  cin >> n >> m;
  for (int64_t i = 0; i <= m; i++) {
    cin >> a;
    v.push_back(a);
  }
  for (int64_t i = 0; i < m; i++) {
    w[v[i]][v[i + 1]]++;
    w[v[i + 1]][v[i]]++;
  }
  dfs(v[0], 1, false);
  if (!fin) {
    cout << "No solution\n";
  } else {
    for (int64_t i : v2) cout << i << ' ';
  }
  return 0;
}
