#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (auto i : v) os << i << " ";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
  for (auto i : v) os << i << " ";
  return os;
}
template <typename T>
T read() {
  char c = getchar();
  T sgn = 1;
  T t = 0;
  while (!isdigit(c)) {
    if (c == '-') sgn = -sgn;
    c = getchar();
  }
  while (isdigit(c)) {
    t *= 10;
    t += c - '0';
    c = getchar();
  }
  return t * sgn;
}
const int N = 2e3 + 233;
int a[N], n, m;
bool vis[N][N];
vector<int> ans;
bool dfs(int val, int id, bool exi) {
  ans[id] = val;
  if (id == m) return exi;
  for (int i = (exi ? 1 : a[id + 1]); i <= n; ++i)
    if (vis[val][i]) {
      vis[val][i] = false;
      vis[i][val] = false;
      if (i != a[id + 1]) {
        if (dfs(i, id + 1, true)) return true;
      } else if (dfs(i, id + 1, exi))
        return true;
      vis[val][i] = true;
      vis[i][val] = true;
    }
  return false;
}
int main() {
  n = read<int>();
  m = read<int>();
  a[0] = read<int>();
  for (int i = 1; i <= m; ++i) {
    a[i] = read<int>();
    vis[a[i]][a[i - 1]] = vis[a[i - 1]][a[i]] = true;
  }
  ans.resize(m + 1);
  if (dfs(a[0], 0, false))
    cout << ans << endl;
  else
    cout << "No solution\n";
  return 0;
}
