#include <bits/stdc++.h>
using namespace std;
bool flag;
int n, m, p[2004], rac[2004], ans[2004];
vector<int> G[104];
int mp[104][104];
void dfs(int now, int big, int fr) {
  if (now == m + 1) {
    if ((!big) || rac[now] != rac[1]) return;
    flag = 1;
    for (int i = 1; i <= m + 1; i++) ans[i] = rac[i];
    return;
  }
  for (int i = 0; i < G[fr].size(); i++) {
    int to = G[fr][i];
    if (!mp[fr][to]) continue;
    if (big) {
      --mp[fr][to];
      --mp[to][fr];
      rac[now + 1] = to;
      dfs(now + 1, big, to);
      if (flag) return;
      ++mp[fr][to];
      ++mp[to][fr];
    } else {
      if (to < p[now + 1]) continue;
      --mp[fr][to];
      --mp[to][fr];
      rac[now + 1] = to;
      dfs(now + 1, big | (to > p[now + 1]), to);
      if (flag) return;
      ++mp[fr][to];
      ++mp[to][fr];
    }
  }
}
int main() {
  flag = 0;
  memset(mp, 0, sizeof(mp));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m + 1; i++) {
    scanf("%d", &p[i]);
    if (i > 1) {
      G[p[i]].push_back(p[i - 1]);
      G[p[i - 1]].push_back(p[i]);
      ++mp[p[i]][p[i - 1]];
      ++mp[p[i - 1]][p[i]];
    }
  }
  for (int i = 1; i <= n; i++) {
    if (G[i].size() > 0) {
      sort(G[i].begin(), G[i].end());
    }
  }
  rac[1] = p[1];
  dfs(1, 0, p[1]);
  if (!flag) {
    return puts("No solution"), 0;
  }
  for (int i = 1; i <= m + 1; i++) printf("%d ", ans[i]);
  puts("");
  return 0;
}
