#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
vector<int> ans, out, input;
set<pair<int, int> > G[105];
pair<int, int> arr[2005];
bitset<2005> vis;
const int INF = 1e9;
void dfs(int u, int bi) {
  while (true) {
    auto p = G[u].lower_bound(make_pair(bi, INF));
    while (p != G[u].end() && vis[p->second]) p = G[u].erase(p);
    if (p == G[u].end()) return ans.push_back(u), void();
    auto tmp = *p;
    G[u].erase(p), vis[tmp.second] = 1, dfs(tmp.first, 0), bi = 0;
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m, st, ls, x;
  cin >> n >> m >> ls, st = ls, input.push_back(st);
  for (int i = 0; i < m; ++i)
    cin >> x, arr[i] = make_pair(ls, x), ls = x, input.push_back(x);
  for (int i = m - 1; i >= 0; --i) {
    int lss = arr[i].second - 1;
    while (true) {
      vis.reset(), ans.clear();
      for (int j = 1; j <= n; ++j) G[j].clear();
      for (int j = m - 1; j >= i; --j)
        G[arr[j].first].insert(make_pair(arr[j].second, j)),
            G[arr[j].second].insert(make_pair(arr[j].first, j));
      auto t = G[arr[i].first].lower_bound(make_pair(lss, INF));
      if (t != G[arr[i].first].end())
        dfs(arr[i].first, t->first), lss = t->first;
      else
        break;
      if (ans.size() + i == m + 1 && ans[0] == st) {
        out.clear();
        for (int j = 0; j < i; ++j) out.push_back(arr[j].first);
        reverse(ans.begin(), ans.end());
        for (int j = 0; j < ans.size(); ++j) out.push_back(ans[j]);
        if (out > input) {
          for (int j = 0; j < out.size(); ++j)
            cout << out[j] << " \n"[j + 1 == out.size()];
          return 0;
        }
      }
    }
  }
  cout << "No solution\n";
}
