#include <bits/stdc++.h>
using namespace std;
int n, m, ff;
vector<int> a, b;
vector<vector<int> > s;
int dp[109][109][2];
int ss[109][109];
bool check() {
  int i;
  for (i = (0); i < (b.size()); ++i) {
    if (b[i] > a[i]) {
      return false;
    }
    if (b[i] < a[i]) {
      return true;
    }
  }
  return true;
}
void fill() {
  int i, j, k;
  for (i = (0); i < (109); ++i) {
    for (j = (0); j < (109); ++j) {
      dp[i][j][0] = dp[i][j][1] = 0;
      ss[i][j] = 0;
    }
  }
}
void dfs(int value, int index, int flag) {
  if (ff == 1) {
    return;
  }
  b[index - 1] = value;
  if (index == m + 1 && value == a[0] && flag == 1) {
    ff = 1;
    return;
  }
  if (index == m + 1) {
    return;
  }
  if (ff == 1) {
    return;
  }
  int i;
  if (flag == 0) {
    for (i = (0); i < (s[value].size()); ++i) {
      int x;
      x = s[value][i];
      if (ss[value][x] == 1) {
        continue;
      }
      if (x < a[index]) {
        continue;
      }
      if (x == a[index]) {
        ss[value][x] = 1;
        ss[x][value] = 1;
        dfs(x, index + 1, 0);
        ss[value][x] = 0;
        ss[x][value] = 0;
        if (ff == 1) {
          return;
        }
        continue;
      }
      if (x > a[index]) {
        ss[value][x] = 1;
        ss[x][value] = 1;
        dfs(x, index + 1, 1);
        ss[value][x] = 0;
        ss[x][value] = 0;
        if (ff == 1) {
          return;
        }
      }
    }
    return;
  }
  for (i = (0); i < (s[value].size()); ++i) {
    int x;
    x = s[value][i];
    if (ss[value][x] == 1) {
      continue;
    }
    ss[value][x] = 1;
    ss[x][value] = 1;
    dfs(x, index + 1, 1);
    ss[value][x] = 0;
    ss[x][value] = 0;
    if (ff == 1) {
      return;
    }
  }
}
int main() {
  fill();
  ff = 0;
  cin >> n >> m;
  s.resize(n);
  int i, x, y;
  cin >> x;
  x--;
  a.push_back(x);
  for (i = (1); i < (m + 1); ++i) {
    cin >> y;
    y--;
    a.push_back(y);
    s[x].push_back(y);
    s[y].push_back(x);
    x = y;
  }
  b = a;
  for (i = (0); i < (b.size()); ++i) {
    b[i] = -1;
  }
  for (i = (0); i < (n); ++i) {
    sort(s[i].begin(), s[i].end());
  }
  b[0] = a[0];
  dfs(a[0], 1, 0);
  if (ff == 0 || check()) {
    cout << "No solution" << endl;
    return 0;
  }
  for (i = (0); i < (b.size()); ++i) {
    cout << b[i] + 1 << " ";
  }
  cout << endl;
  return 0;
}
