#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y;
  int to(int n) { return n == x ? y : x; }
} bian[2020];
vector<int> v[110];
int a[2020], i, n, m;
bool used[2020] = {0};
stack<int> sta;
bool cmp(int a, int b) { return bian[a].to(i) < bian[b].to(i); }
bool dfs(int p, int step, bool st) {
  if (step == m) return !st && p == a[0];
  bool ans = 0;
  for (int i = 0; i < v[p].size(); i++) {
    if ((!st || bian[v[p][i]].to(p) >= a[step]) && !used[v[p][i]]) {
      used[v[p][i]] = 1;
      ans = dfs(bian[v[p][i]].to(p), step + 1,
                st && bian[v[p][i]].to(p) == a[step]);
      used[v[p][i]] = 0;
    }
    if (ans) {
      sta.push(bian[v[p][i]].to(p));
      break;
    }
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  m++;
  for (i = 0; i < m; i++) {
    scanf("%d", &a[i]);
    a[i]--;
  }
  for (i = 1; i < m; i++) {
    bian[i].x = a[i];
    bian[i].y = a[i - 1];
    v[a[i - 1]].push_back(i);
    v[a[i]].push_back(i);
  }
  for (i = 0; i < n; i++) sort(v[i].begin(), v[i].end(), cmp);
  if (!dfs(a[0], 1, 1))
    printf("No solution\n");
  else {
    sta.push(a[0]);
    while (!sta.empty()) {
      printf("%d", sta.top() + 1);
      sta.pop();
      printf("%c", sta.empty() ? '\n' : ' ');
    }
  }
}
