#include <bits/stdc++.h>
using namespace std;
vector<int> v[105];
int n, m, arr[2005], arr1[2005], f[105][105], f1[105], c1;
bool d, vis[105];
void dfs(int x, int y, int p) {
  int i;
  for (i = 0; i < v[x].size(); i++) {
    if (f[x][v[x][i]] && f1[v[x][i]] && v[x][i] >= y) {
      f1[v[x][i]]--;
      f[x][v[x][i]] = f[v[x][i]][x] = 0;
      dfs(v[x][i], -1, p);
    }
  }
  arr1[c1++] = x;
}
int main() {
  int i, j, k;
  scanf("%d%d", &n, &m);
  for (i = 0; i <= m; i++) {
    scanf("%d", &arr[i]);
    if (i >= 1) {
      v[arr[i]].push_back(arr[i - 1]);
      v[arr[i - 1]].push_back(arr[i]);
    }
  }
  for (i = 1; i <= n; i++) sort(v[i].begin(), v[i].end());
  for (i = m - 1; i > 0; i--) {
    for (j = 1; j <= n; j++) {
      f1[j] = 0;
      for (k = 0; k < v[j].size(); k++) f[j][v[j][k]] = 1;
    }
    for (j = 1; j < i; j++) {
      f[arr[j - 1]][arr[j]] = f[arr[j]][arr[j - 1]] = 0;
    }
    for (j = i; j <= m; j++) f1[arr[j]]++;
    f1[arr[0]]--;
    c1 = 0;
    d = 0;
    dfs(arr[i - 1], arr[i] + 1, arr[0]);
    if (c1 == m - i + 1 && f[arr1[0]][arr[0]]) {
      for (j = 0; j < i; j++) {
        if (j)
          printf(" %d", arr[j]);
        else
          printf("%d", arr[j]);
      }
      for (j = c1 - 2; j >= 0; j--) printf(" %d", arr1[j]);
      printf(" %d\n", arr[0]);
      break;
    }
  }
  if (i == 0) printf("No solution\n");
  return 0;
}
