#include <bits/stdc++.h>
using namespace std;
const int MaxN = 102, MaxL = 2005, MaxC = 0x3F3F3F3F, NA = -1;
vector<int> a[MaxN];
bool b[MaxN];
int p[MaxL];
int m, n;
void recur(int v) {
  if (b[v]) return;
  b[v] = true;
  for (vector<int>::iterator it = a[v].begin(); it != a[v].end(); it++)
    recur(*it);
}
bool euler(int v) {
  int i;
  for (i = 1; i <= n; i++)
    if ((a[i].size() ^ (i == v) ^ (i == p[0])) & 1) return false;
  memset(b, 0, sizeof(b));
  recur(v);
  for (i = 1; i <= n; i++)
    if (a[i].size() > 0 && !b[i]) return false;
  return true;
}
int main(void) {
  int i, j, k, l;
  bool ok;
  while (scanf(" %d %d", &n, &m) != EOF) {
    for (i = 1; i <= n; i++) a[i].clear();
    for (i = 0; i <= m; i++) scanf(" %d", &p[i]);
    assert(p[0] == p[m]);
    ok = false;
    l = NA;
    for (i = m; i > 0; i--) {
      j = p[i - 1];
      k = p[i];
      a[j].push_back(k);
      sort(a[j].begin(), a[j].end());
      a[k].push_back(j);
      sort(a[k].begin(), a[k].end());
      ok = false;
      l = NA;
      for (vector<int>::iterator it = find(a[j].begin(), a[j].end(), k) + 1;
           it != a[j].end() && !ok; it++) {
        l = *it;
        a[j].erase(find(a[j].begin(), a[j].end(), l));
        a[l].erase(find(a[l].begin(), a[l].end(), j));
        if (euler(l)) {
          ok = true;
          break;
        }
        a[j].push_back(l);
        sort(a[j].begin(), a[j].end());
        a[l].push_back(j);
        sort(a[l].begin(), a[l].end());
      }
      if (ok) break;
    }
    if (i == 0)
      printf("No solution\n");
    else {
      for (i++; i <= m; i++) {
        p[i - 1] = j = l;
        ok = false;
        l = NA;
        for (vector<int>::iterator it = a[j].begin(); it != a[j].end() && !ok;
             it++) {
          l = *it;
          a[j].erase(find(a[j].begin(), a[j].end(), l));
          a[l].erase(find(a[l].begin(), a[l].end(), j));
          if (euler(l)) {
            ok = true;
            break;
          }
          a[j].push_back(l);
          sort(a[j].begin(), a[j].end());
          a[l].push_back(j);
          sort(a[l].begin(), a[l].end());
        }
        assert(ok);
      }
      for (i = 0; i <= m; i++) printf("%d%c", p[i], " \n"[i == m]);
    }
  }
  return 0;
}
