#include <bits/stdc++.h>
using namespace std;
struct arc {
  int nxt;
  int dest;
  int used;
};
arc l[4444];
int beg[111];
int el = 0;
int n, m;
inline void addArc(int source, int dest) {
  l[el].dest = dest;
  l[el].used = 0;
  l[el].nxt = beg[source];
  beg[source] = el++;
}
int way[2222];
int ans[2222];
int eans = 0;
int change = -1;
int changelen = -1;
int go = -1;
struct comp {
  bool operator()(const int a, const int b) const {
    return l[a].dest < l[b].dest;
  }
};
bool DFS(int v, int len, bool was = false) {
  ans[len] = v;
  if (len == m) return was;
  bool can = false;
  vector<int> pos;
  for (int nxt = beg[v]; nxt != -1; nxt = l[nxt].nxt) {
    pos.push_back(nxt);
  }
  sort(pos.begin(), pos.end(), comp());
  for (int i = 0; i < pos.size(); i++) {
    int nxt = pos[i];
    if (l[nxt].used == 0) {
      if (was || l[nxt].dest >= way[len]) {
        l[nxt].used = l[nxt ^ 1].used = len;
        if (DFS(l[nxt].dest, len + 1, was | l[nxt].dest > way[len])) {
          return true;
          can = true;
        }
        l[nxt].used = l[nxt ^ 1].used = 0;
      }
    }
  }
  return can;
  if (can) {
    return true;
  } else {
    change = v;
    changelen = len;
    int mn = 0x7f7f7f7f;
    for (int nxt = beg[v]; nxt != -1; nxt = l[nxt].nxt) {
      if (l[nxt].used == 0 && l[nxt].dest > way[len]) mn = min(mn, l[nxt].dest);
    }
    if (mn < 0x7f7f7f7f) {
      go = mn;
      return true;
    }
    return false;
  }
}
void DFS1(int v, int len) {
  if (len == changelen) {
    for (int nxt = beg[v]; nxt != -1; nxt = l[nxt].nxt) {
      if (l[nxt].dest == go) {
        l[nxt].used = l[nxt ^ 1].used = true;
        break;
      }
    }
    DFS1(go, len + 1);
  } else {
    if (len < changelen) {
      for (int nxt = beg[v]; nxt != -1; nxt = l[nxt].nxt) {
        if (l[nxt].used == 0 && l[nxt].dest == way[len]) {
          l[nxt].used = l[nxt ^ 1].used = len;
          DFS1(l[nxt].dest, len + 1);
        }
      }
    } else {
      vector<int> pos;
      for (int nxt = beg[v]; nxt != -1; nxt = l[nxt].nxt) {
        pos.push_back(nxt);
      }
      sort(pos.begin(), pos.end(), comp());
      for (int i = 0; i < pos.size(); i++) {
        int nxt = pos[i];
        if (l[nxt].used == 0) {
          l[nxt].used = l[nxt ^ 1].used = len;
          DFS1(l[nxt].dest, len + 1);
        }
      }
    }
  }
  ans[eans++] = v;
}
vector<int> ll[111];
int main() {
  memset(beg, -1, sizeof beg);
  cin >> n >> m;
  int prv;
  cin >> prv;
  way[0] = prv;
  for (int i = 1; i <= m; i++) {
    int cur;
    cin >> cur;
    way[i] = cur;
    addArc(cur, prv);
    addArc(prv, cur);
    prv = cur;
  }
  way[m + 1] = 0x7f7f7f7f;
  if (DFS(way[0], 1, false)) {
    for (int u = 1; u <= m; u++) cout << ans[u] << ' ';
    cout << way[0];
  } else {
    cout << "No solution";
  }
  cout << endl;
  return 0;
}
